-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix scroll restoration when redirecting in an action #9886
Fix scroll restoration when redirecting in an action #9886
Conversation
🦋 Changeset detectedLatest commit: 4d7ed68 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
restoreScrollPosition: getSavedScrollPosition( | ||
location, | ||
newState.matches || state.matches | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We always try to restore - that never should have been conditional on submissions
(state.navigation.formMethod != null && | ||
isMutationMethod(state.navigation.formMethod) && | ||
location.state?._isRedirect !== true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, don't reset on non-redirecting submission navigations
@brophdawg11 – this is great but unfortunately |
Thanks @nrako, I transferred that issue to the react router repo and will try to take a look this week 👍 |
Closes #9577
This also introduces
<Form preventScrollReset>
and fixes an underlying bug where we were preventing restore on submissions when we should be preventing reset 😬 . We always restore if we have a previous known position (which we never do by default because we uselocation.key
).New semantics: