-
Notifications
You must be signed in to change notification settings - Fork 51
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
Restore scroll position on navigation #43
Comments
A reference to the pwa-helpers router: Polymer/pwa-helpers#14 |
Any option similar to Polymer/pwa-helpers#14? |
do we have some kind of advance for this issue? |
Related example: https://stackblitz.com/edit/lit-element-demo-zejjsv Steps:
It seems that the problem is the lazy load of the view using dynamic Now If you uncomment the static imports, it always keeps the scroll: import './views/home-view.js';
import './views/profile-view.js';
import './views/not-found-view.js'; |
There are any workaround with this? Thanks in advance! |
One way to reset scroll position would be to add a listener for the window.addEventListener('vaadin-router-location-changed', e => {
window.scrollTo(0, 0);
}); A more elaborate solution would require changes in the Router APIs.
|
Thanks for the answer, @vlukashov! I discard the first option because in many situations we shouldn't scroll to top. As before I was using the |
Adding a link to the Vue router implementation for reference. |
I think we should use the |
Note: as discussed today with https://vaadin.com team, we might try It supports all the target browsers of Vaadin 15 (don't be confused with Edge 80, the data seems to be incorrect). IMO this is something worth prototyping to see if it works for us. |
Just opening up a discussion here: Should we consider the use case of scrolling to an anchor in the page instead of a scroll position? |
Any news here? |
Very interested too in this feature and in the scroll to anchor from @miladkdz |
Hi, any updates on this issue? |
Not sure if I have a special case, but for me scroll is restored properly on page changes, but when I go to a new page, it doesn't move the scroll position to the top. So I'm pretty confused. At the very least, if we had something like For example, change src/triggers/popstate.js to:
And then do something similar in Ultimately, I think saving and restoring the scroll position should be a top priority. I've used the router in a few places, and this issue is mysteriously present or not, and I can't figure out why. When it is present, it is a debilitating user experience. |
Hello, any updates?👀 |
It's not ideal, but we have a simple patch to deal with it here: IBM/pwa-lit-template#1 |
As Flow I want Vaadin.Router to support restoring scroll position on navigation in the same way it works in Flow 1.0 so that the future versions of Vaadin Flow could switch to Vaadin.Router instead of the own implementation.
NOTE: react-router does not have any explicit support for scroll position restoration. Their position is that browsers do that by default quite well already: https://reacttraining.com/react-router/web/guides/scroll-restoration
The text was updated successfully, but these errors were encountered: