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

Scroll position saving #336

Open
arctic-hen7 opened this issue Jan 25, 2022 · 5 comments
Open

Scroll position saving #336

arctic-hen7 opened this issue Jan 25, 2022 · 5 comments
Labels
A-router Area: router C-enhancement Category: new feature or improvement to existing feature
Milestone

Comments

@arctic-hen7
Copy link
Contributor

In Firefox (I'm not sure about other browsers from memory), the default behavior when using the forward/back button is to restore the scroll position for greater continuity. However, Sycamore breaks this behavior by resetting the scroll position to the top of the page.

In a way, this is a bug report about that, but it's also a broader feature request for the router to track scroll positions and automatically restore them upon navigating to a page that the user has been to before in the same session. I'm not sure this would be best done by storing every single scroll position, but rather perhaps for the last 10 pages or so. This could even maybe be configured by some router initialization parameter (though that would be a later feature for a breaking release).

Pending confirmation on this design, I'm very happy to work on this.

@arctic-hen7 arctic-hen7 added the C-enhancement Category: new feature or improvement to existing feature label Jan 25, 2022
@lukechu10 lukechu10 added the A-router Area: router label Jan 25, 2022
@lukechu10
Copy link
Member

I think it's worth looking into how other SPA routers do this (in particular, sveltekit's router or https://github.com/solidjs/solid-app-router). Also if you don't mind, I would like to merge the new reactivity system before you work on this because that would likely cause a lot of merge conflicts.

@arctic-hen7
Copy link
Contributor Author

Sure thing, I'll look into those! I completely understand about the new reactive primitives, no problem! (Also thank you so much for all your hard work on them, I have no doubt that they'll be absolutely incredible!)

@arctic-hen7
Copy link
Contributor Author

arctic-hen7 commented Jan 25, 2022

For reference, this issue from Solid seems to have a fair bit of discussion on the matter. I think a good solution might be store previous scroll positions in the router in some way and then allow the app to control the behavior from there. That way, Sycamore provides helpers but not lock-ins, which is probably better in the long-run.

@lukechu10 lukechu10 added this to the v0.8 milestone Jun 8, 2022
@lukechu10
Copy link
Member

I'd like to tentatively get this in for the 0.8 release

@arctic-hen7
Copy link
Contributor Author

Yeah that would be great. If you'd like me to do it, I should be able to have a look next week.

@lukechu10 lukechu10 removed this from the v0.8 milestone Jul 25, 2022
@lukechu10 lukechu10 added this to the v0.9 milestone Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-router Area: router C-enhancement Category: new feature or improvement to existing feature
Projects
None yet
Development

No branches or pull requests

2 participants