Pressing BACK button from product page should return user to their spot in the Collection page

Topic summary

A Shopify store owner using the Nimbus theme reports that when users navigate back from a product page to a collection page, they are returned to the top instead of their previous scroll position. This creates a poor browsing experience, especially with hundreds of products per collection.

Key Details:

  • Issue occurs specifically on iOS mobile devices
  • Only happens when collection pages use “infinite scroll” or “Show More” button settings
  • Theme developer claims this requires custom code and additional payment, though the feature appears to work in the demo store

Proposed Solution:
A community member provided JavaScript code using sessionStorage to:

  • Save scroll position when users click product links
  • Restore position when returning to collection pages
  • Clear stored position after restoration

The original poster confirmed needing adaptation for infinite scroll/show more functionality. The discussion remains ongoing, with the solution provider offering to continue troubleshooting via WhatsApp to address the dynamic content loading requirements.

Summarized with AI on October 27. AI used: claude-sonnet-4-5-20250929.

I’m currently on Nimbus theme and have hundreds of products on each Collection page. When a user browses a collection >>clicks on a product >> then clicks the back button, the user should be brought back to the position of the product they last viewed so that they can continue browsing where they left off. However, this theme currently brings the user all the way back to the top of the collection and the user has to scroll all the way down again to go back to their position. This is an annoying and terrible user experience. Can someone provide a solution for this?

1 Like

Could you please share your store URL and password [if applicable] so that I can take a look and provide you solution code.

Looking forward to hearing back from you.

Thanks

Hi Artey,
This feature should be supported by the theme by default.
I tried the Nimbus demo store. It works as you expected, have you updated to latest version of the theme?

Yes we’re on the latest version. I agree with you . This needs to be supported by the theme by default. But they’re saying it requires a custom code and saying we should pay extra for it.

I think I should have been more clear: the issue I think only appears on IOS mobile and when the collection page is set to be on infinite scroll or “Show More” button. this URL has this setting: https://cot1gzifpty4hdgx-58770456708.shopifypreview.com

Solution: Save and Restore Scroll Position Using JavaScript

We’ll use sessionStorage to save the user’s scroll position when they click a product, and then restore that position when they return to the collection page.

Step 1: Add JavaScript to Save and Restore Scroll Position

In your Shopify admin, go to Online Store > Themes > Edit Code. Then, in your theme.liquid file, just before the closing tag, insert the following script:

Saves the vertical scroll position (window.scrollY) when a product link is clicked.

When the user returns to a collection page, the script checks for the saved scroll position and restores it.

After restoring the scroll position, the script removes the stored value to prevent it from affecting future navigation.

If your theme uses AJAX navigation or infinite scroll, you may need to adapt the script slightly. For example, you could wrap the window.scrollTo call in a setTimeout or wait for a custom event that indicates the collection has finished rendering.

With this script in place, users who view a product and then return to the collection page will land exactly where they left off, providing a smooth and intuitive browsing experience.

If you need help integrating this into a theme using dynamic content loading or if you’re unsure where to place the code in your theme’s structure, let me know and I’ll guide you step-by-step.

Hi there, thanks for the reply! Yes, my theme has the option for the collection page to have infinite scroll or show more button. I would like users to be able to return to their position when infinite scroll or show more setting is activated on collection pages. How do I adapt this code to work for both settings?

Are you currently on WhatsApp? If yes Drop your WhatsApp we will discuss
this effectively and resolve everything for you, I’m currently working on
an e-commerce store like yours to help it out.