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
window does not scroll on top when switching routes #1099
Comments
This isn't a concern with the router itself. The probable solution would be to have a |
@hamza1311 should we consider making this an option with the new |
"new user"? I think we should make this the default with an option to opt out (for cases like Discord, where the URL defines which node should be in view). I wonder how other routers (angular/vue/react router) do this |
Sorry, meant to write new router but got distracted and my fingers decided to type something on their own :D |
Yes. That's what causes the router example to stay in weird position when switching routes, requiring manual scroll-up |
I know it is been a while, but the issue is still there. Prob for starters a simple reset with |
@hamza1311 @futursolo |
I think you can replicate this behaviour with the following code. let location = use_location();
use_effect_with_deps(|_| {
window.scroll_to(ScrollToOptions::new().top(0));
}, location); You can extend the above by storing the data in |
I ended up with the following implementation: Cargo.toml
helper function
calling it like
The question is - do you think this kind of functionality should reside in the the router code itself? |
I am not sure if it is on purpose, but right now when routes are switched the scrollbar is not reset to the (0,0) position. What is a suitable workaround?
The text was updated successfully, but these errors were encountered: