Skip to content

Back button broken on anchor links with Turbo disabled #709

Open
@littleforest

Description

@littleforest

We are trying to add Turbo 8 (using morphing) to an existing project. Since the project is quite large, we have Turbo disabled globally, but are turning it on for one particular page. However, the back button for our anchor links on the non-Turbo pages no longer works as expected. We have tried disabling Turbo through Turbo.session.drive = false as well as just setting data-turbo="false" on the body tag.

Here is a small Rails example that reproduces this. In the example, Turbo.session.drive is set to false, and clicking the anchor link on the /home/index page correctly jumps to the anchor. However, when clicking the back button, nothing happens. Clicking the back button a second time will bring the user back to the top of the page. On the /home/turbo page, Turbo is turned on and the anchor link works as expected with the correct back button behavior.

I noticed that clicking the anchor link on the /home/index page does not cause the data-turbo-visit-direction="forward" to get applied to the html tag. However, when clicking the back button, data-turbo-visit-direction gets set to "back" and nothing happens.

Image

The back button for links to-and-from Turbo to non-Turbo pages work as expected.

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