router icon indicating copy to clipboard operation
router copied to clipboard

Hash history router doesn't scroll to top when visiting a new page

Open kottkrig opened this issue 10 months ago • 2 comments

Which project does this relate to?

Router

Describe the bug

When using hash history via createHashHistory, navigation to new pages doesn't scroll to the top of the page. Instead it seems to keep the scroll position from the original page.

Your Example Website or App

https://stackblitz.com/edit/github-4rybtq-5mekkq2j?file=src%2Froutes%2Findex.tsx,src%2Froutes%2Fabout.tsx,src%2Fmain.tsx

Steps to Reproduce the Bug or Issue

  1. Scroll down
  2. Click on "Go to about"
  3. Confirm that you are in a scrolled state

Expected behavior

As a user, I expect to go to the top of /about when I haven't been there before. Instead I end up scrolled to the middle of the page.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Arc
  • Version: Chromium Engine Version 133.0.6943.35

Additional context

The incorrect behaviour is only visible when using "hash history". When using default browser history the navigation behaves as expected.

kottkrig avatar Feb 19 '25 12:02 kottkrig

Had to revert #3700 in #3702 due to an unintended bug that it introduced in Start.

SeanCassiere avatar Mar 09 '25 07:03 SeanCassiere

@SeanCassiere Do you have any updates about when this might get merged again?

BrendanC23 avatar Jun 09 '25 20:06 BrendanC23

Thanks for the fix!

BrendanC23 avatar Jul 27 '25 02:07 BrendanC23