Fix scroll position not resetting when navigating between pages#2917
Open
cqnykamp wants to merge 1 commit into
Open
Fix scroll position not resetting when navigating between pages#2917cqnykamp wants to merge 1 commit into
cqnykamp wants to merge 1 commit into
Conversation
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
Contributor
Author
|
This PR is ready for review @cqnykamp. CI is running — I'll monitor it and address any failures. Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
$(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.tsxusesoverflowY="auto"on aGridItemelement, making that element (notwindow) the scroll container. React Router's built-in scroll restoration only operates onwindow, so scroll position was never reset between page navigations.Fix
ScrollToTopcomponent inside the main contentGridItemthat resetsscrollTopto0whenever the routepathnamechanges viauseLocation+useEffect.data-test="Main Content"attribute to the scrollable container for testability.mainRefinSiteContextso child components can programmatically interact with the scroll container if needed.Test plan
packages/e2e-tests/e2e/Activities/scrollReset.cy.tsverifies that navigating to a different page resets the scroll position to 0https://claude.ai/code/session_01GkbCKnBr4VvMojBVuhULKd
EOF
)
Generated by Claude Code