fix(router-core): stop forcing history.scrollRestoration to 'manual' - #8347
fix(router-core): stop forcing history.scrollRestoration to 'manual'#8347Ishkirat-Singh wants to merge 1 commit into
Conversation
setupScrollRestoration forced history.scrollRestoration to 'manual'. That setting only governs the window, and the router restores the window after paint (in the onRendered subscriber) while the browser's native restoration runs before it: forcing manual mode made iOS Safari's swipe-back preview land at the wrong offset and made Chrome paint at the top and snap down after a hard refresh. Per-element restoration and the router's own window correction are unaffected by the flag, so stop changing it. Closes TanStack#7956
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe router no longer forces ChangesScroll restoration behavior
Priority: ➖ Normal Estimated code review effort: 1 (Trivial) | ~5 minutes Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to This PR removes the conflicting manual scroll setting and keeps native browser restoration enabled. No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The PR removes the forced 'manual' assignment and preserves the existing restoration logic. However, linked issue Resolution Implement the linked issue's required pre-paint router scroll work, including PUSH scroll-to-top and traversal restoration, or update the issue linkage and scope to confirm that this PR addresses only the history.scrollRestoration assignment.
✨ 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 #7956 (follow-up to #7815).
setupScrollRestorationstill sethistory.scrollRestoration = 'manual'wheneverscrollRestoration: true. Forcing manual mode turns off the browser's native pre-paint restore, which is what iOS Safari's swipe-back preview and Chrome's hard refresh rely on: Safari repainted at the wrong offset after the gesture, and Chrome painted at the top and snapped down a frame later. The router's own restore runs post-paint in theonRenderedsubscriber; it still runs, still corrects the window position and still restores individual scroll containers, none of which depend on manual mode.This PR removes the assignment and leaves
history.scrollRestorationon the browser default. As discussed in the issue it is a plain removal rather than an option: no case was found where'manual'restores better than native restore plus the router's corrector, so an opt-in would only preserve the regression path.packages/router-core/src/scroll-restoration.ts: drop thehistory.scrollRestoration = 'manual'assignment.packages/router-core/tests/scroll-restoration.test.ts: the setup test now asserts thatscrollRestorationstays'auto', with a comment explaining why.@tanstack/router-core(patch).✅ Checklist
🚀 Release Impact
Summary by CodeRabbit