TanStack / TanStack/router

Pending Component does not receive scroll restoration logic

Open
#7,749 0 comments 1 reaction 0 assignees View on GitHub

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
  1. Go to Reproduction
  2. Scroll to Bottm of index page
  3. Click Link to next page
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.