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 broken on anchor links with Turbo disabled #709

Open
littleforest opened this issue Jan 14, 2025 · 0 comments
Open

Back button broken on anchor links with Turbo disabled #709

littleforest opened this issue Jan 14, 2025 · 0 comments

Comments

@littleforest
Copy link

littleforest commented Jan 14, 2025

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.

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

1 participant