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
|
Name | Type |
---|---|
@remix-run/router | Patch |
react-router-dom | Minor |
react-router | Minor |
react-router-dom-v5-compat | Minor |
react-router-native | Minor |
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 |
* Fix scroll restoration when redirecting in an action (remix-run#9815) * Add preventScrollReset prop to Form Co-authored-by: Johann R <johann.rakotoharisoa@gmail.com>
Closes #9577
This also introduces😬 . We always restore if we have a previous known position (which we never do by default because we use
<Form preventScrollReset>
and fixes an underlying bug where we were preventing restore on submissions when we should be preventing resetlocation.key
).New semantics: