Pending Component does not receive scroll restoration logic
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.1k
- Forks
- 1.9k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 143
Description
Which project does this relate to?
Router
Describe the bug
When scrolled down on a page and linking to another, the pending component appears scrolled to the bottom, as opposed to being at the top on first load. The page then jumps to the top at the end of the pending period.
Complete minimal reproducer
https://stackblitz.com/~/github.com/alex-delia/profile-scroll-reset-repro
Steps to Reproduce the Bug
- Go to Reproduction
- Scroll to Bottm of index page
- Click Link to next page
- Observe pending component showing the bottom instead of top of the page
This also includes a potential workaround where It uses the router's 'onBeforeNavigate' event to scroll to the top of the page
Expected behavior
Scroll restoration currently executs in the onRendered stage of the router's events. This means anything like pending components dont receive the expected scrolling behaviour on load. I would expect the pending component to match the actual components logic, so things like full page skeleton loaders work properly.
Screenshots or Videos
https://github.com/user-attachments/assets/c20f6e2f-0b05-4bf9-b228-ba36fc642952
Platform
- Router / Start Version: @tanstack/react-router 1.170.17 (router-core 1.171.14). TanStack Start: N/A
- OS: macOS 15.7.7
- Browser: Google Chrome
- Browser Version: 149.0.7827.201
- Bundler: Vite
- Bundler Version: 6.4.3
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal StackBlitz reproducer and inspect the router's onRendered scroll-restoration stage alongside the onBeforeNavigate workaround. Reproduce the transition from the bottom of the index page, then trace pending-component rendering; done means the pending component starts at the top and no later jump occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100