Skip to content
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

Add ignoreScrollBehavior to new API #522

Merged
merged 3 commits into from
Nov 26, 2014

Conversation

gaearon
Copy link
Contributor

@gaearon gaearon commented Nov 26, 2014

This PR exposes ImitateBrowserBehavior and ScrollToTopBehavior and reintroduces ignoreScrollBehavior which allows you to opt out of scrolling changes within bounds of some ancestor route.

This was already implemented in #388 but it is missing in new API so I'm reimplementing it.
This PR adds test for ScrollToTopBehavior but lacks tests for ignoreScrollBehavior. I'll add these shortly.

@gaearon gaearon force-pushed the reimplement-ignore-scroll branch 2 times, most recently from 68fbbfb to a505143 Compare November 26, 2014 14:57
@gaearon
Copy link
Contributor Author

gaearon commented Nov 26, 2014

Just added the new tests. One last thing I'd like to do in this PR is to incorporate changes I made in #477.
I'll add this as a separate commit (with test changes).

@mjackson
Copy link
Member

@gaearon This looks great! Thank you.

I'll wait until you're ready to merge.

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
@gaearon gaearon force-pushed the reimplement-ignore-scroll branch from 83125d6 to 5fe6c08 Compare November 26, 2014 15:47
@gaearon
Copy link
Contributor Author

gaearon commented Nov 26, 2014

@mjackson Consider this one ready.

@gaearon
Copy link
Contributor Author

gaearon commented Nov 26, 2014

Let's hold this off for a moment. I think there's a bug in current RR scrolling code, I might fix it here as well.

@gaearon
Copy link
Contributor Author

gaearon commented Nov 26, 2014

Nevermind, this code is fine. The issue I'm experiencing is unrelated so let's bring this in.

mjackson added a commit that referenced this pull request Nov 26, 2014
@mjackson mjackson merged commit 7e9aead into remix-run:master Nov 26, 2014
@mjackson
Copy link
Member

Thanks @gaearon !

@rpflorence Let's cut a new release with this stuff. 0.12?

@gaearon
Copy link
Contributor Author

gaearon commented Nov 26, 2014

@mjackson I want to also do #480 today, can we hold off the release?

@gaearon gaearon deleted the reimplement-ignore-scroll branch November 26, 2014 17:38
@mjackson
Copy link
Member

@gaearon By all means, be my guest ;)

@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants