Canceling `turbo:click` does not stop a frame navigation.
See original GitHub issueLooking at the turbo:click
docs:
Cancel this event to let the click fall through to the browser as normal navigation.
Though if your link triggers a frame navigation, running preventDefault()
doesn’t cancel it.
document.addEventListener('turbo:click', (e) => e.preventDefault())
on a Visit:
document.addEventListener('turbo:click', (e) => e.preventDefault())
on a frame:
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Navigate with Turbo Drive - Hotwire Turbo
Restoration visits cannot be canceled and do not fire turbo:before-visit . Turbo Drive issues restoration visits in response to history navigation that has ......
Read more >can only interact with a turbo frame once? #249 - GitHub
I click edit, update, click save, and the change is reflected. However if I try to do this another time on the same...
Read more >Turbo Frames and Turbo Stream templates - Hotrails
Rule 2: When clicking on a link within a Turbo Frame, if there is no Turbo Frame with the same id on the...
Read more >Adding Interactivity with Turbo Frames - Medium
Turbo Frames capture navigation. Within a Turbo Frame, any link clicks or form submissions will, by default, capture the server response, ...
Read more >Turbo-frame with Devise, after a successful update user, on ...
By making your edit action responding with a turbo_stream you will be assured that it gets replaced accordingly. Share.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That is a decision that pre-dates my involvement in the project: https://github.com/hotwired/turbo/blame/v7.0.0-beta.1/src/core/frames/link_interceptor.ts#L39-L40
I’m in favor of experimenting with a different implementation, and support some trial and error with the hopes that the test suite will guide us!
I’m not sure it’s possible to cancel frames only looking at
turbo:click
with the current architecture 🤔 What was the reason #412 was reverted?As a possible workaround, we can do something like https://github.com/hotwired/turbo/pull/788, which adds a new
turbo:frame-click
event that controls frame clicks and can be canceled 🤷