Fix element scroll restoration reset#7710
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughFixes a bug where DOM elements restored from scroll cache were subsequently reset to Element scroll restoration fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
Summary
Fixes #7687.
When a non-window scroll target is restored from the scroll restoration cache, the later scroll-to-top fallback can still reset that same element if it is also listed in
scrollToTopSelectors. This keeps track of restored elements duringonRenderedand skips those elements when applying the fallback reset.Validation
npm_config_cache=/tmp/codex-npm-cache npx -y pnpm@11.9.0 --filter @tanstack/history buildnpm_config_cache=/tmp/codex-npm-cache npx -y pnpm@11.9.0 --filter @tanstack/router-core exec vitest run tests/scroll-restoration.test.tsSummary by CodeRabbit