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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Submitter detaching issue #6
Comments
Hi! :) Would #4 (or a similar implementation) solve this issue by preventing item 2 in your list from happening? |
This could potentially be fixed in Rails too by changing its assumption that the clicked submit button is still connected: --- a/activestorage/app/javascript/activestorage/ujs.js
+++ b/activestorage/app/javascript/activestorage/ujs.js
@@ -58,7 +58,11 @@ function handleFormSubmissionEvent(event) {
}
function submitForm(form) {
- let button = submitButtonsByForm.get(form) || findElement(form, "input[type=submit], button[type=submit]")
+ let button = submitButtonsByForm.get(form)
+
+ if (!button || !button.isConnected) {
+ button = findElement(form, "input[type=submit], button[type=submit]")
+ } |
I don't believe so, as Rails is capturing the click event on document.
Yes. But since this deviates from then native |
The only functional difference is that the polyfilled version results in a submit button
I鈥檓 leaning towards this being an issue/bug with Rails and not this polyfill, and here鈥檚 why: the same problem could occur without Here鈥檚 a minimal
|
Fair. It's true that no other solutions would really be bulletproof for a polyfill. Feel free to close this. Thanks! |
Hi @javan 馃憢馃徎,
I found this while working with
activestorage/ujs.js
. I thought it's worth opening an issue here because the code works when there's native support forform.requestSubmit
.Specifically, this is the ordering of events for the problematic flow:
polyfill
: Submission triggered by arequestSubmit
callactivestorage/ujs.js
:didClick
stores the submitter created by the polyfill in the WeakMappolyfill
: callsremoveChild
, the submitter is detachedactivestorage/ujs.js
: handles async uploadactivestorage/ujs.js
: gets the submitter fromWeakMap
andclick()
, which does not do anything sincesubmitter.form
is nownull
.And here's a test page for a simplified test case. Form submits in Chrome, but not in Safari.
A potential fix I can think of would be firing a submit event instead of creating/appending/removing a submitter. What do you think?
The text was updated successfully, but these errors were encountered: