hydrogen
hydrogen copied to clipboard
Scroll restoration on `body` element
Issue reported on Discord:
When navigating the site, and it doesn't take you back to the top of the page, is there a specific anchor link that the default demo-store has that may have been overlooked? Does anyone know what that scroll to top functionality is expecting?
This problem appears when the website has overflow: hidden in the <html> element and relies on <body> scroll instead.
Hydrogen restores the scroll by calling window.scrollTo, which doesn't affect <body> scroll.
A quick workaround is running window.scrollTo = (x,y) => document.body.scrollTo(x,y) before navigating to other pages.
Should we provide a way to customize the way we restore scroll? Or perhaps just add docs on this?