fix(router-core): preserve pending scroll reset - #8245
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe router now preserves pending scroll-reset intent across same-path URL patches. It stores the intent in history state, tracks pending restoration, applies the destination marker during rendering, and adds regression tests. ChangesPending scroll reset preservation
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Pending page scroll resets are now retained through same-path URL updates without exposing router bookkeeping in user history state. Regression coverage covers the affected navigation sequence, and no merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant Navigation
participant RouterCore
participant History
participant ScrollRestoration
participant Window
Navigation->>RouterCore: commit same-path URL patch
RouterCore->>History: store resetScrollStateKey
RouterCore->>ScrollRestoration: mark pending reset
ScrollRestoration->>ScrollRestoration: read destination reset marker
ScrollRestoration->>Window: scroll to top
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 5 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎯 Changes
Fixes #8028.
resetScroll: falsebefore the navigation has rendered.Tests run:
CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache -- tests/scroll-restoration.test.ts -t "preserves a pending page reset"CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache -- tests/scroll-restoration.test.ts -t "pending"CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache -- tests/scroll-restoration.test.tsCI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache -- tests/build-location.test.tsCI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:types --outputStyle=stream --skipRemoteCacheCI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCacheCI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:eslint --outputStyle=stream --skipRemoteCacheCI=1 NX_DAEMON=false pnpm test:eslintCI=1 NX_DAEMON=false pnpm test:typesCI=1 NX_DAEMON=false pnpm test:unit✅ Checklist
🚀 Release Impact
Summary by CodeRabbit