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

Back button and scroll position #33

Open
acasar opened this issue Jul 3, 2023 · 2 comments
Open

Back button and scroll position #33

acasar opened this issue Jul 3, 2023 · 2 comments

Comments

@acasar
Copy link

acasar commented Jul 3, 2023

Usually when clicking the browser's back button, the scroll position of the previous page is preserved. However when using the turbo router this is not the case - the page is always opened at the top.

Would it be possible to somehow make turbo router mimic the default browser behaviour in this situation and preserve the scroll position?

@daftspunk
Copy link
Member

Hi @acasar

We may need to see your issue demonstrated.

There is code in place specifically for this and it appears to be working on our side. Here you can see the scroll position is remembered for each snapshot:

Scroll-Position

@acasar
Copy link
Author

acasar commented Jul 4, 2023

@daftspunk I did some more tests and the issue is indeed only present in some scenarios. I was able to reproduce it on a default OctoberCMS installation like so:

  1. Open the default demo page
  2. Scroll to the footer and click "AJAX Demo"
  3. Click the browser's back button

You are returned to the top of the home page instead of to the bottom. When turbo router is disabled the scroll position is correctly preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants