-
Notifications
You must be signed in to change notification settings - Fork 26
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
Mismatch between scroll and focus handling #231
Comments
This came up in discussion with @annevk as well; it slipped out of my brain before I could file it. Thanks for finding this and bringing it up. The desire for symmetry between scroll and focus is indeed what makes this hard. A quick fix would be to add a The cross-document nav experience is:
The current navigation API default experience for same-document navs is:
We've been treating focus restore as something that we can't do by default, because of the problem of identifying the "same" DOM element. That seems like a safe bet to me. But we could probably fix the scroll reset/restore behavior. Proposal:
These are both compat-impacting changes. They would bring us to The proposed navigation API default experience for same-document navs is:
which is close to the cross-document nav experience. |
The case I'm unsure about is hash-change navigations. I'm happy with |
If you call Whereas, if anyone was using the hash to store information that was not a target element (e.g., UI state like which tab was open) they might want resetting behavior... So I think it would be OK.
That's a good point, and it would be nice to unify. However:
These are not very strong objections, so if we can think of a good name it still might be better to combine. |
I can't think of a good name either. Given the above, it seems fine for them to be seperate options. |
#237 is about a different problem, but its solution will probably be part of the same API, and subsume what we're talking about here. So people interested should follow both issues. |
This changes the default behavior of intercepted navigations with respect to scrolling in the following ways: * Scroll restoration is performed on reloads, not just traverses. * For pushes and replaces, we either scroll to the top or scroll to the fragment. This change requires some updated API surface: the scrollRestoration option to intercept() has become scroll, and the navigateEvent.restoreScroll() method has become navigateEvent.scroll(). Closes #237 by giving an easy default behavior for SPA navigations with hashes. Closes #231 by making "push", "replace", and "reload" behave by default in an MPA-like manner with respect to scroll position, just like "traverse" does.
This changes the default behavior of intercepted navigations with respect to scrolling in the following ways: * Scroll restoration is performed on reloads, not just traverses. * For pushes and replaces, we either scroll to the top or scroll to the fragment. This change requires some updated API surface: the scrollRestoration option to intercept() has become scroll, and the navigateEvent.restoreScroll() method has become navigateEvent.scroll(). The latter method now has more capabilities, working to give browser-default-like behavior for "push", "replace", and "reload" in addition to "traverse". Similar to before, all of this can be opted out of by using scroll: "manual". Closes #237 by giving an easy default behavior for SPA navigations with hashes. Closes #231 by making "push", "replace", and "reload" behave by default in an MPA-like manner with respect to scroll position, just like "traverse" does.
This changes the default behavior of intercepted navigations with respect to scrolling in the following ways: * Scroll restoration is performed on reloads, not just traverses. * For pushes and replaces, we either scroll to the top or scroll to the fragment. This change requires some updated API surface: the scrollRestoration option to intercept() has become scroll, and the navigateEvent.restoreScroll() method has become navigateEvent.scroll(). The latter method now has more capabilities, working to give browser-default-like behavior for "push", "replace", and "reload" in addition to "traverse". Similar to before, all of this can be opted out of by using scroll: "manual". Closes #237 by giving an easy default behavior for SPA navigations with hashes. Closes #231 by making "push", "replace", and "reload" behave by default in an MPA-like manner with respect to scroll position, just like "traverse" does.
The default focus behaviour is to reset focus, which is appropriate behaviour if the page is changing significantly, but not in cases like tabbed navigation.
This behaviour was decided in #202 to match MPA behaviour.
However, it seems like current scroll behaviour is out of step with this intent. In a regular MPA, when you navigate via either push/replace, scrolling is reset to 0,0. It feels like this should happen here too.
I'm not sure if this should be rolled into the current scroll option, or whether it needs a separate
scrollReset
option.The text was updated successfully, but these errors were encountered: