Skip to content

Scroll preservation persists globally after visiting a page with data-turbo-action="advance" #1344

@Jamie-Vandenbalck

Description

@Jamie-Vandenbalck

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions