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

Frames: Ignore already cancelled submit events #459

Merged
merged 1 commit into from
Nov 22, 2021

Conversation

seanpdoyle
Copy link
Contributor

Closes hotwired/turbo#243

In tandem with rails/rails#41960 (which shipped as part of
7.0.0.alpha2), this commit modifies the FormInterceptor to ignore
submit events that have been cancelled.

Although it doesn't test the integration directly, the cancellation of
the submit event is what powers the ActiveStorage.js direct upload
asynchrony. Following a direct upload, ActiveStorage dispatches a
synthetic submit event, which the FormInterceptor will then respond
to.

Closes [hotwired#243][]

In tandem with [rails/rails#41960][] (which shipped as part of
`7.0.0.alpha2`), this commit modifies the `FormInterceptor` to ignore
`submit` events that have been cancelled.

Although it doesn't test the integration directly, the cancellation of
the `submit` event is what powers the ActiveStorage.js direct upload
asynchrony. Following a direct upload, ActiveStorage dispatches a
synthetic `submit` event, which the `FormInterceptor` will then respond
to.

[hotwired#243]: hotwired#243
[rails/rails#41960]: rails/rails#41960
@CharlieIGG
Copy link

So what happens if we ever DO want to have Turbo handle a previously default-prevented form submission?

@dhh dhh merged commit 078441a into hotwired:main Nov 22, 2021
@seanpdoyle seanpdoyle deleted the frame-ignored-cancelled-submit branch November 22, 2021 12:32
@seanpdoyle
Copy link
Contributor Author

@CharlieIGG what are the circumstances under which Turbo would be handling an event that was canceled?

ActiveStorage relies on cancelling the submit, handling direct uploads, then programatically click an input[type="submit"] button to synthesize a separate submit event. Maybe applications could deploy the same pattern if they needed to.

@CharlieIGG
Copy link

That actually makes perfect sense, thank you for the clarification @seanpdoyle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Active Storage direct uploads
3 participants