Skip to content

Fix scroll position not resetting when navigating between pages#2917

Open
cqnykamp wants to merge 1 commit into
mainfrom
claude/modest-franklin-ACWBM
Open

Fix scroll position not resetting when navigating between pages#2917
cqnykamp wants to merge 1 commit into
mainfrom
claude/modest-franklin-ACWBM

Conversation

@cqnykamp

Copy link
Copy Markdown
Contributor

$(cat <<'EOF'

Summary

Fixes #2828 (scroll position persists when navigating to another page) and also addresses #2656 (activity viewer loads off-screen after navigating from a scrolled Explore page).

Root Cause

The main content area in SiteHeader.tsx uses overflowY="auto" on a GridItem element, making that element (not window) the scroll container. React Router's built-in scroll restoration only operates on window, so scroll position was never reset between page navigations.

Fix

  • Added a ScrollToTop component inside the main content GridItem that resets scrollTop to 0 whenever the route pathname changes via useLocation + useEffect.
  • Added a data-test="Main Content" attribute to the scrollable container for testability.
  • Exposed mainRef in SiteContext so child components can programmatically interact with the scroll container if needed.

Test plan

  • New e2e test in packages/e2e-tests/e2e/Activities/scrollReset.cy.ts verifies that navigating to a different page resets the scroll position to 0
  • Manually: scroll down on any page, navigate to another page via the navbar — verify new page starts at the top
  • Manually: scroll down on Explore, click an activity — verify the activity viewer loads at the top of the screen

https://claude.ai/code/session_01GkbCKnBr4VvMojBVuhULKd
EOF
)


Generated by Claude Code

Adds a ScrollToTop component inside the main content area that resets
scrollTop to 0 whenever the route pathname changes. The main GridItem
already had overflowY="auto", meaning scroll state lived in that element
rather than the window, so React Router's built-in scroll restoration
didn't apply. Also exposes mainRef via SiteContext and adds a data-test
attribute for testability.

Fixes #2828, also addresses #2656 (activity viewer loading off-screen
after navigating from scrolled Explore page).

Adds e2e test to verify scroll position resets on navigation.

https://claude.ai/code/session_01GkbCKnBr4VvMojBVuhULKd

Copy link
Copy Markdown
Contributor Author

This PR is ready for review @cqnykamp. CI is running — I'll monitor it and address any failures.


Generated by Claude Code

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.

Bug When Navigating to Another Page After Scrolling Down

2 participants