hotwired / turbo-rails

Use Turbo in your Ruby on Rails app
https://turbo.hotwired.dev
MIT License
2.09k stars 322 forks source link

Turbo refresh can hijack user navigation #622

Closed klevo closed 5 months ago

klevo commented 5 months ago

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:

https://github.com/hotwired/turbo-rails/assets/32981/48f438a6-244f-4070-9439-44044c043d92

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 commented 5 months ago

Thank you for opening this issue. Could this unexpected behavior be resolved by https://github.com/hotwired/turbo/pull/1213?

klevo commented 5 months ago

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

klevo commented 5 months ago

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

Therefore I'm closing this issue.