-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Which project does this relate to?
Router
Describe the bug
Starting on page A, if I scroll somewhere and then navigate to from pages A -> B -> C with resetScroll=false and without scrolling the page on B, the scroll position is maintained as expected. However, when navigating back to B with the back arrow, it resets the scroll position back to the top. Then going back to A remembers the original scroll position on A.
This is presumably because no scroll event happened on page B, so it didn't store any scroll position information for the entry for B at that point. I suspect when using resetScroll=false it should copy over A's scroll position entry to B when the navigation happens.
This also appears to happen when using a nested scrollable element with scrollToTopSelectors.
Your Example Website or App
https://github.com/TomVHPresto/scroll-restoration-mcve
Steps to Reproduce the Bug or Issue
- Start on page /a
- Scroll down some amount
- Click any link to go to /b
- Do not scroll on /b and click a link to go to /c
- Click the back arrow in the browser - /b scrolls to the top of the page
Expected behavior
I would expect scroll position to be remembered for /b when going back from /c.
Screenshots or Videos
No response
Platform
- Router Version: 1.158.0
- OS: Windows
- Browser: Chrome
- Browser Version: 144.0.7559.110
- Bundler: vite
- Bundler Version: 7.3.1
Additional context
No response