Skip to content

Scroll position should be remembered for intermediate pages when navigating with resetScroll=false #6595

@TomVHPresto

Description

@TomVHPresto

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

  1. Start on page /a
  2. Scroll down some amount
  3. Click any link to go to /b
  4. Do not scroll on /b and click a link to go to /c
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions