Skip to content
Source
Sign inSign up
TanStack/router

[Router] - Page briefly jumps to the top before restoring scroll on reload #8502

ClosedAndresuito(GitHub profile, opens in a new tab) opened this issue 0 comments

Which project does this relate to?

Router

Describe the bug

When reloading a page after scrolling down, the page briefly jumps to the top and then returns to the position where it was reloaded.

The final scroll position is correct. The problem is the visible jump before restoration completes. I observe this in Chrome and Safari, including when running this minimal example in development mode. It can be intermittent, so repeated reloads may be necessary.

Complete minimal reproducer

https://github.com/Andresuito/tanstack-scroll-repro

Steps to Reproduce the Bug

  1. Start the application with pnpm dev and open the URL printed by Vite in Chrome or Safari.
  2. Scroll down to approximately section 10.
  3. Wait a moment, then reload the page with Command + R on macOS.
  4. Watch the page briefly show the pink header at the top before returning to the previous scroll position.
  5. Repeat the reload several times if it does not happen initially. Also try a hard reload (Command + Shift + R in Chrome), and specify which reload method is shown in the attached video.

Expected behavior

Reloading should preserve the previous scroll position without visibly jumping to the top first.

Screenshots or Videos

https://github.com/user-attachments/assets/be23538c-d1dd-4bc3-b10c-d41e9cb1b331

Second 0:13 (Second video)

https://github.com/user-attachments/assets/4ea19d13-a5e3-49ac-bd8f-b45ace2bc3f9

https://github.com/user-attachments/assets/c4f6a1cb-3440-41f6-b650-568db0a3e501

Platform

  • Router version: @tanstack/react-router 1.170.39
  • Start version: @tanstack/react-start 1.168.58
  • OS: macOS — add your macOS version
  • Browser: Chrome and Safari
  • Browser versions: add the versions used for the recording
  • Bundler: Vite
  • Bundler version: 8.3.1
  • React / React DOM: 19.3.0
  • Server adapter: Nitro 3.0.260903-beta

Additional context

Issues https://github.com/TanStack/router/issues/7815 https://github.com/TanStack/router/issues/7956

Sign in to join this conversation.