fix: scroll restoration when navigating back from an OSS program detail page to the listing page - #439
fix: scroll restoration when navigating back from an OSS program detail page to the listing page#439yshishir wants to merge 2 commits into
Conversation
|
@yshishir is attempting to deploy a commit to the AJEET PRATAP SINGH's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThe dashboard now identifies its scrollable main element, saves the OSS programs scroll position when navigating through a program link, and restores that position when the programs list mounts. ChangesDashboard scroll restoration
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant ProgramCard
participant sessionStorage
participant ProgramsList
participant dashboard-scroll-container
ProgramCard->>dashboard-scroll-container: Read scrollTop before navigation
dashboard-scroll-container-->>ProgramCard: Current scroll position
ProgramCard->>sessionStorage: Save oss-programs-scroll
ProgramsList->>sessionStorage: Read saved position on mount
sessionStorage-->>ProgramsList: Saved scroll position
ProgramsList->>dashboard-scroll-container: Restore scrollTop
ProgramsList->>sessionStorage: Remove saved position
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/web/src/components/oss-programs/ProgramCard.tsx (1)
14-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the
sessionStoragekey into a shared constant.The string
"oss-programs-scroll"is used here and inProgramsList.tsx(lines 17 and 22). Extracting it to a shared constant prevents key drift if one file is updated but not the other.♻️ Suggested shared constant
+// shared constant, e.g. in a constants file or at the top of a shared utils module +export const OSS_PROGRAMS_SCROLL_KEY = "oss-programs-scroll";Then use it in both files:
onClick={() => { const scrollContainer = document.getElementById("dashboard-scroll-container"); sessionStorage.setItem( - "oss-programs-scroll", + OSS_PROGRAMS_SCROLL_KEY, String(scrollContainer?.scrollTop ?? window.scrollY) ); }}🤖 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 `@apps/web/src/components/oss-programs/ProgramCard.tsx` around lines 14 - 20, Extract the "oss-programs-scroll" sessionStorage key into a shared constant, then update the onClick handler in ProgramCard and the corresponding storage usages in ProgramsList to reference that constant instead of duplicating the string.
🤖 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 `@apps/web/src/components/oss-programs/ProgramCard.tsx`:
- Around line 14-20: Extract the "oss-programs-scroll" sessionStorage key into a
shared constant, then update the onClick handler in ProgramCard and the
corresponding storage usages in ProgramsList to reference that constant instead
of duplicating the string.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2b2dfe41-06ec-4d12-9ddc-eba3cbf67891
📒 Files selected for processing (3)
apps/web/src/app/(main)/dashboard/layout.tsxapps/web/src/app/(main)/dashboard/oss-programs/ProgramsList.tsxapps/web/src/components/oss-programs/ProgramCard.tsx
|
@apsinghdev can you look into this |
Fixes #437
While coming back to the oss program detail page to the listing page, the scroll should also restore to the same place as it was before.
here is the demo-
Screencast.from.2026-07-14.01-47-38.webm
what's changed
idto the dashboard scroll container instead of relying on a genericmainselector.Summary by CodeRabbit