Skip to content

fix: scroll restoration when navigating back from an OSS program detail page to the listing page - #439

Open
yshishir wants to merge 2 commits into
apsinghdev:mainfrom
yshishir:fix/scroll-issue
Open

fix: scroll restoration when navigating back from an OSS program detail page to the listing page#439
yshishir wants to merge 2 commits into
apsinghdev:mainfrom
yshishir:fix/scroll-issue

Conversation

@yshishir

@yshishir yshishir commented Jul 13, 2026

Copy link
Copy Markdown

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

  • Saves the dashboard scroll container position before opening a program detail page.
  • Restores the saved scroll position when the OSS programs list mounts.
  • Adds a stable id to the dashboard scroll container instead of relying on a generic main selector.

Summary by CodeRabbit

  • Bug Fixes
    • Preserved the dashboard’s scroll position when navigating away from and returning to the OSS programs list.
    • Restored the saved position consistently across dashboard layouts and screen sizes.

@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

@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.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Dashboard scroll restoration

Layer / File(s) Summary
Expose container and capture position
apps/web/src/app/(main)/dashboard/layout.tsx, apps/web/src/components/oss-programs/ProgramCard.tsx
Dashboard main elements share a stable identifier, and program links save the current scroll position in sessionStorage.
Restore position on list mount
apps/web/src/app/(main)/dashboard/oss-programs/ProgramsList.tsx
ProgramsList restores the saved scroll position on mount and removes the stored value.

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
Loading

Suggested reviewers: apsinghdev, huamanraj

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements the issue’s requirements by saving the scroll position on navigation away and restoring it after the list mounts.
Out of Scope Changes check ✅ Passed The changes all support scroll restoration for the OSS programs page and do not introduce unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: restoring scroll position when returning from an OSS program detail page to the listing page.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/web/src/components/oss-programs/ProgramCard.tsx (1)

14-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the sessionStorage key into a shared constant.

The string "oss-programs-scroll" is used here and in ProgramsList.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

📥 Commits

Reviewing files that changed from the base of the PR and between 46c9e0d and 297d371.

📒 Files selected for processing (3)
  • apps/web/src/app/(main)/dashboard/layout.tsx
  • apps/web/src/app/(main)/dashboard/oss-programs/ProgramsList.tsx
  • apps/web/src/components/oss-programs/ProgramCard.tsx

@yshishir yshishir closed this Jul 17, 2026
@yshishir yshishir reopened this Jul 17, 2026
@yshishir

Copy link
Copy Markdown
Author

@apsinghdev can you look into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Maintain scroll position across page navigation

1 participant