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

Turbo refresh can hijack user navigation #622

Closed
klevo opened this issue Apr 20, 2024 · 3 comments
Closed

Turbo refresh can hijack user navigation #622

klevo opened this issue Apr 20, 2024 · 3 comments

Comments

@klevo
Copy link

klevo commented Apr 20, 2024

There is a race condition with Turbo 8 refreshes and regular user clicks through the application.

It's rather easy to observe when there is a consistent stream of refreshes generated and user navigates through the pages steadily.

When a refresh broadcast comes in just after the user click, it overrides the user generated turbo visit and the visitor stays on the same page.

Here's a video of the issue:

turbo-refresh-overriding-user-visit.mov
  • At the end you can observe I click on "Show this item" of the item named "Two", yet I remain on the index page. You can notice the desired page blinked in and out for a few microseconds too.
  • The cause is visible in the console: The second to last turbo visit to /items/2 is my user initiated action.
  • The following (last) entry in the console is the turbo refresh of the current /items page that just arrived (you can see the Updated at times changed from from :05 to :06). This refresh essentially hijacked my click and resulted in me staying on the index page.

This is on Safari 17.4.1. I also replicated the same issue in latest Chrome.

I created a simple Rails 7.1 app to demonstrate the issue that is used in the above video with full instructions.

@seanpdoyle
Copy link
Contributor

Thank you for opening this issue. Could this unexpected behavior be resolved by hotwired/turbo#1213?

@klevo
Copy link
Author

klevo commented Apr 20, 2024

@seanpdoyle I tested it but unfortunately it does not solve the issue. The problem remains the same.

@klevo
Copy link
Author

klevo commented Apr 21, 2024

I figured out the actual issue and the fix, it's the debouncing within Turbo lib itself. I opened a PR there: hotwired/turbo#1250

Therefore I'm closing this issue.

@klevo klevo closed this as completed Apr 21, 2024
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