fix(sistent): preserve sidebar scroll position across navigation - #7924
fix(sistent): preserve sidebar scroll position across navigation#7924dhruveshmishra wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR addresses #7911 by preserving the Sistent TOC sidebar’s scroll position across page navigations using sessionStorage.
Changes:
- Add a
refto the TOC list container so itsscrollTopcan be read/written. - Persist the TOC scroll offset to
sessionStorageon scroll. - Restore the previous scroll offset on mount via
useEffect.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe navigation component tracks the TOC list with a ref. It restores the saved scroll position from ChangesTOC scroll position persistence
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: dependency version conflict. Check your lock file or package.json. 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 |
14bc27f to
a8ab03b
Compare
Signed-off-by: dhruveshmishra <dhruveshmishra09@gmail.com>
a8ab03b to
f14803f
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/SistentNavigation/index.js (1)
81-81: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winCoalesce the
sessionStoragewrite during scrolling.
onScrollfires repeatedly during a continuous scroll.sessionStorage.setItemis synchronous, so this handler can reduce scroll responsiveness. Keep the latest offset in a ref and throttle or debounce the write. Flush the latest value before navigation if the write is deferred.As per coding guidelines, “debounce or throttle expensive event handlers” and maintain or improve Core Web Vitals.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/SistentNavigation/index.js` at line 81, Update the toc-list scroll handler in SistentNavigation to store the latest scrollTop in a ref and coalesce sessionStorage writes through throttling or debouncing instead of writing synchronously on every scroll event. Ensure the deferred latest offset is flushed before navigation, while preserving the existing "sistent-toc-scroll" persistence behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/components/SistentNavigation/index.js`:
- Line 81: Update the toc-list scroll handler in SistentNavigation to store the
latest scrollTop in a ref and coalesce sessionStorage writes through throttling
or debouncing instead of writing synchronously on every scroll event. Ensure the
deferred latest offset is flushed before navigation, while preserving the
existing "sistent-toc-scroll" persistence behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 2f3e7cda-a798-431d-9097-86994b40d50d
📒 Files selected for processing (1)
src/components/SistentNavigation/index.js
Description
This PR fixes #7911
Preserves the scroll position of the Sistent TOC sidebar across page navigations by storing the scroll offset in sessionStorage on scroll and restoring it on component mount.
Screen recording
Screen.Recording.2026-08-05.at.12.44.09.AM.mov
Summary by CodeRabbit