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 preservation persists globally after visiting a page with data-turbo-action="advance" #1344

Open
Jamie-Vandenbalck opened this issue Dec 1, 2024 · 1 comment

Comments

@Jamie-Vandenbalck
Copy link

Description:

When navigating to a page (e.g., the blog index) that uses data-turbo-action="advance", Turbo starts preserving scroll positions globally for all subsequent navigations, even on pages that do not use data-turbo-action="advance". The issue only occurs after visiting the page with this attribute—if the page is never visited, scroll behavior works as expected.

Steps to Reproduce:

  1. Add data-turbo-action="advance" to a link on the blog index page (/blog):
<turbo-frame id="blog_posts" src="{{ path('app.blog.index', routeParams) }}"data-turbo-action="advance">
  1. Visit the /blog page.
  2. Navigate to an unrelated page (e.g., /about) using a standard Turbo-enabled link: <a href="/about">About</a>
  3. Observe that the scroll position on the /about page is preserved from the /blog page, even though data-turbo-action="advance" is not used on the /about page.

Expected Behavior:

Scroll preservation should only apply:

  • Within the context of the /blog page where data-turbo-action="advance" is explicitly used.
  • Scroll position should reset appropriately when navigating to unrelated pages (e.g., /about).

Actual Behavior:

  • After visiting the /blog page and using data-turbo-action="advance", Turbo globally preserves scroll positions across all subsequent pages.
  • This behavior persists for unrelated pages (e.g., /about), even if they do not use data-turbo-action="advance".
  • If the /blog page is not visited, scroll behavior works as expected, resetting to the top for each new page.

Environment:

Turbo Version: 8.0.11
Browser: Safari 18.1.1, Chrome 131
Operating System: macOS 15.1.1

@nicowenterodt
Copy link

Yea. I see the same with data-turbo-action="replace"

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