-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Preserving scroll position when changing path query #432
Comments
#439 seems related |
(total hack, but for now you can do some work in |
There's no
That's precisely what
(You'll need 0.9.x at least) |
I just tried |
Previously, the only way to opt out of scroll updates for a route would be by using `ignoreScrollBehavior`. This, however, made it hard to implement arguably the most common use case: resetting scroll when `params` change and preserving it when only `query` changes. This commit completely disables scroll updates when only `query` has changed. This provides a reasonable default behavior and leaves `ignoreScrollBehavior` for more complicated cases. If you'd rather keep the old behavior and reset scroll on query changes, you can either promote `query` variables to be route `params` or reset scroll position yourself in response to `query` changes in route handler's `componentDidUpdate`. Fixes remix-run#432, remix-run#439
Reopening this issue (previously: #337) since the changes don't seem to encompass this use case.
I'd like to preserve scroll position on a page when adding some query arguments to the URL but haven't figured out a way to do it.
If I set
preserveScrollPosition
for the page's route, it fixes the issue but causes the scroll position to be preserved coming from other pages as well. I also tried matching the query arguments in another Route, but was unable to match a?
literal.Example code:
When transitioning from
/items/
to/items/?filter=blue
the page scrolls back up to the top and there's no way to control the behavior.The text was updated successfully, but these errors were encountered: