New issue
Advanced search Search tips

Issue 887935 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Sep 25
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Disabling a submit button in its onclick handler prevents form submission

Reported by mendesj...@gmail.com, Sep 21

Issue description

Chrome Version       : Version 68.0.3440.75 (Official Build) (64-bit)
URLs (if applicable) : https://jsfiddle.net/mendesjuan/jfauzkh8/ https://stackoverflow.com/a/52443415/227299
Other browsers tested:
  Add OK or FAIL, along with the version, after other browsers where you
have tested this issue:
     Safari Version 12.0 (13606.2.11): FAIL
    Canary: FAIL
    Firefox: OK
       IE11: OK

What steps will reproduce the problem?

(1) Have a <form> with a <button type="submit"> inside that has an inline click handler to disable the submit button
(2) Click the submit button

What is the expected result?

The form is submitted and the button is disabled while the page is waiting.


What happens instead?

The button is disabled but the form never submits.


Additional information

This bug does not happen if you use addEventListener on Chrome, but still happens in Safari.

If you handle it in the form.onsubmit inline, the the form does submit.



 
Forgot to mention that a setTimeout also solves the problem :)
Components: Blink>Forms>Submission
Labels: Needs-Milestone
Components: -Blink>Forms>Submission Blink>Forms>Button
Owner: tkent@chromium.org
Status: WontFix (was: Unconfirmed)
The behavior of Chrome and Safari is correct according to the specification.

https://html.spec.whatwg.org/multipage/form-elements.html#the-button-element:the-button-element-2
> if this element is not disabled,

Then why is the behavior different when registering an event handler with JavaScript? Is that a bug?
I didn't see any behavior difference between onclick= and addEventListener('click', ...).

The fiddle that I mentioned in the bug behaves differently, https://jsfiddle.net/mendesjuan/jfauzkh8/ . It has;

*  An example of setting it through attributes, where the form doesn't submit
*  An example of setting it with addEventListener, where the form does submit

Did you look at it and the explanation in the stack overflow posts? Also note that the behavior in FF and IE is consistent. Chrome/Safari have problems.
> *  An example of setting it with addEventListener, where the form does submit

No. https://jsfiddle.net/mendesjuan/jfauzkh8/ doesn't have addEventListener.

Sorry. Even the example I had in the SO question mentioned, `addEventListener` also stops the form from submitting (submit event from being fired). 

I will note in the SO question that the behavior is accurate according to the spec, inconsistent with IE and FF and that the correct thing to do anyway is to handle it in the submit event.

Thanks.

Sign in to add a comment