Page not starting on scroll position top
Hello, when I scroll on my /post route and navigate to /post/$postId, it doesn't reset the scroll position. Anyone has an idea why so?
7 Replies
correct-apricotOP•3mo ago
I have set
scrollRestoration: true in my router.ts
and I also tried to use resetScroll on the <Link> elementadverse-sapphire•3mo ago
do you have a different scroll container than window?
correct-apricotOP•3mo ago
yes
adverse-sapphire•3mo ago
so you need to set scrollToTopSelectors
https://tanstack.com/router/v1/docs/framework/react/guide/scroll-restoration#scroll-to-top--nested-scrollable-areas
Scroll Restoration | TanStack Router React Docs
Hash/Top-of-Page Scrolling Out of the box, TanStack Router supports both hash scrolling and top-of-page scrolling without any additional configuration. Scroll-to-top & Nested Scrollable Areas By defau...
correct-apricotOP•3mo ago
ah I see, thank you so much
I think I try first to avoid a scrollable container
adverse-sapphire•3mo ago
why though? does it not work with
scrollToTopSelectors ?correct-apricotOP•3mo ago
Sorry, didn't see the message earlier. No, it works perfectly. I just a general preference. I want to be able to scroll the content, not only by hovering over the container