Open fregante opened 2 years ago
I like the idea of matching the browser here. Making in-flight requests cancelable with esc. Please do explore.
I'd love to see this eventually in Turbo. I tried looking into it and there doesn't seem to be any way to cancel these events completely.
Turbo allows "cancellation" of turbo:click
and turbo:before-render
but both of them cause Turbo to set location.href
and trigger a full-page reload. "Cancellation" refers to the AJAX loading, not just to the loading.
Regular navigation in the browser can be stopped by clicking the browser’s "Stop loading" button or by hitting the ESC key. Turbo does not handle this and requests cannot be cancelled after
fetch
is made.I looked into the code and I have not found a way to implement this myself outside Turbo:
request.cancel
is present but not accessible from the eventI wish Turbo would either:
event.detail.cancel()
on one of the early events, likeclick
(since history events cannot be cancelled) so that it can be called at any time beforerender
, orPrior art