-
-
Notifications
You must be signed in to change notification settings - Fork 125
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 scroll-related options to useRouter() #791
Comments
Thanks for reporting. waku/packages/waku/src/router/client.ts Line 428 in 4986822
Ah, I see. So, the current behavior is intentional. Do you want to keep the scroll position if only query param changes? Can you investigate how other frameworks handle it? |
btw, I think |
I've investigated this issue and found an interesting approach in Next.js. They use session storage to save scroll coordinates, as shown in this code: While this method might seem a bit hacky, it provides a smooth user experience. I think it would be beneficial if Waku could implement a similar feature, allowing developers to optionally decide whether to preserve scroll position when pushing new routes or updating query parameters. I'd like to propose a new approach for Waku. The proposed method is The advantages of this approach are:
This method could be simpler yet effective. It also seems like a good way to improve user experience while maintaining Waku's philosophy of API extensibility. I'd be happy to work on a pull request to implement this feature if you're interested. What do you think about this approach? Please let me know if there are any additional considerations or modifications needed. |
I agree that we shouldn't use sessionStorage. I agree adding an option |
Yes, it would be nice for router.back() to have a similar option - or default to this behavior so it is similar to hitting the back button in the browser. |
Yes, we would like to make it the default behavior (prefer less options), using Would you like to work on it? |
Hello,
I've noticed a bug-like behavior when handling state with query parameters. Every time the query changes, the scroll position resets to the top of the page. This can be disruptive to the user experience, especially on pages with a lot of content.
To address this, I suggest adding scroll-related options to the useRouter() hook. This would allow developers to control scroll behavior when navigating or updating query parameters.
If you're open to it, I'd be willing to work on this feature. Would you be interested in a pull request that implements this functionality?
Thank you for your consideration.
The text was updated successfully, but these errors were encountered: