Repository navigation
Conversation
Client-side navigations no longer keep the previous page's scroll position, and back/forward restores it. Part of openedx#318. Co-Authored-By: Claude <noreply@anthropic.com>
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.
Description
This is the scroll half of #318. The shell runs a React Router data router but never rendered
<ScrollRestoration />, and a data router leaves the scroll position alone without it. So moving between pages without a reload, starting from a page you'd scrolled down, landed you halfway down the next one, in every app.It's now rendered once, in the root route's component,
shell/Shell.tsx, which fixes it for all apps at once. Each new navigation starts at the top, and back/forward puts you back where you were.The catch: a navigation that only rewrites the address, like a filter in the query string, now also jumps to the top unless it passes
preventScrollReset. frontend-base's own code has none of those: its onlynavigate()call is the masquerade redirect, which goes to a different tab and should reset. Apps might, though, so there's a short note in the migration how-to, and converted apps that keep filters or pagination in the query string should add the option before they pick this up. Learning already does, in openedx/frontend-app-learning#2267.The pending-navigation indicator, the other half of #318, is left for a later PR.
LLM usage notice
Built with assistance from Claude.