-
Notifications
You must be signed in to change notification settings - Fork 428
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
Enable opting-out of form submissions #3
Conversation
31e6404
to
6629df9
Compare
7c40e23
to
5f9a25f
Compare
6629df9
to
76aa42e
Compare
42aa483
to
03a9e01
Compare
76aa42e
to
4af85e7
Compare
03a9e01
to
24f02a1
Compare
4af85e7
to
bf257f3
Compare
24f02a1
to
5277f6b
Compare
5277f6b
to
dfe80fc
Compare
dfe80fc
to
f151ec4
Compare
f151ec4
to
a8cc662
Compare
bfc5b88
to
07feddf
Compare
Would this be a good place to incorporate the changes from https://github.com/turbolinks/turbolinks/pull/495/files? I've not manually tested Turbo Drive with non-fetch form submissions, but from the look of turbo/src/core/drive/history.ts Line 35 in c52d87c
After a traditional POST, calling I'd be happy to port these changes over if there's interest? |
07feddf
to
cb2669f
Compare
My I ask when would this be merged? 😂😂 Quite a few issues are depending on this to be fixed. It's preventing me to use hotwire to do so many things. |
b33bc20
to
f381ac5
Compare
132d36c
to
803bf0d
Compare
Similar to [Disabling Turbo Drive on Specific Links][turbo-drive-false], guard intercepting form subissions with a similar check for `[data-turbo-drive="false"]` on the submitter, `<form>` element, or an ancestor. Similarly, *do not intercept* when the submitter or form element specifies a method that isn't an HTTP verb (via [formmethod="dialog"][formmethod] attribute or [method="dialog"][method] attribute, respectively). In practice, HTTP submitting `<form>` elements will only ever declare `method="get"` or `method="post"`. The one [exceptional case is `method="dialog"`][method-dialog], which we check for as a special case. Testing --- Since we're covering behavior for the `<dialog>` element _and_ running the suite in both Chrome and Firefox, the test suite needs to polyfill support for the `<dialog>` element. [turbo-drive-false]: https://turbo.hotwire.dev/handbook/drive#disabling-turbo-drive-on-specific-links [formmethod]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formmethod [method]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-method [method-dialog]: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-2
803bf0d
to
7e0ea5b
Compare
It’s enough to test that Turbo doesn’t handle form submissions when method=dialog or formmethod=dialog.
Just adding in case other folks come around, I believe contrary to the initial description of this PR, the necessary attribute on the But this is well-documented on https://turbo.hotwire.dev/handbook/drive#disabling-turbo-drive-on-specific-links-or-forms In Rails parlance, form_with model: @xyz, url: etc, data: { turbo: false } Which is great because |
Follow-up to hotwired#3 --- When a `<form data-turbo-frame="...">` element is submitted, it's handled by the `Frames/FormInterceptor` class instead of the `FormSubmitObserver` class, which was originally fixed to cover this behavior in [hotwired#3][]. This commit reproduces the fix so that it's consistent across `<form>` elements, regardless of their targetting. [hotwired#3]: hotwired#3
Follow-up to #3 --- When a `<form data-turbo-frame="...">` element is submitted, it's handled by the `Frames/FormInterceptor` class instead of the `FormSubmitObserver` class, which was originally fixed to cover this behavior in [#3][]. This commit reproduces the fix so that it's consistent across `<form>` elements, regardless of their targetting. [#3]: #3
Similar to Disabling Turbo Drive on Specific Links,
guard intercepting form subissions with a similar check for
[data-turbo-drive="false"]
on the submitter,<form>
element, or anancestor.
Similarly, do not intercept when the submitter or form element
specifies a method that isn't an HTTP verb (via
formmethod="dialog" attribute or method="dialog"
attribute, respectively).
In practice, HTTP submitting
<form>
elements will only ever declaremethod="get"
ormethod="post"
. The one exceptional case ismethod="dialog"
, which we check for as a special case.Testing
Since we're covering behavior for the
<dialog>
element and runningthe suite in both Chrome and Firefox, the test suite needs to polyfill
support for the
<dialog>
element.