W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2012

[whatwg] HTMLForms: Implicit Submission with {display:none} button

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 22 Feb 2012 00:35:35 +0000 (UTC)
Message-ID: <Pine.LNX.4.64.1202212256500.1688@ps20323.dreamhostps.com>
On Sat, 24 Sep 2011, Kaustubh Atrawalkar wrote:
> On 24-Sep-2011, at 12:24 AM, Ian Hickson <ian at hixie.ch> wrote:
>> On Fri, 23 Sep 2011, Kaustubh Atrawalkar wrote:
>>> 
>>> If the form has submit button with display property as none, will that 
>>> form should be implicitly submitted on pressing enter key? This works 
>>> in Opera & Firefox but does not work in IE & Safari as of now. What is 
>>> the expected behavior for this?
> 
>> The strict answer is that it's up to the browsers; the spec allows 
>> browsers to do whatever they think is appropriate per their platform's 
>> conventions. So both behaviours are compliant.
> 
> But then this might result in website compliance issue. A website having 
> username, password field with hidden submit button expecting to login on 
> enter key using forms implicit submission will work on FF & Opera but 
> may not work on IE & Safari.

Yes. Similarly, some browsers might provide spelling checking, and others 
might not. Some might support tabbing from field to field, others might 
not. The thing is, if a platform does not have the concept of implicit 
submission, presumably the user wouldn't try to implicitly submit anything 
in the first place, so it doesn't matter if the browser does it or not.


>> The guidelines in the spec do not say anything about the behaviour 
>> being different for elements that are display:none or otherwise hidden, 
>> though, so I don't see any reason to consider the visibility of a 
>> button in making the decision as to which button is the default.
> 
> Second to your opinion, on the last line of the specs paragraph it says 
> - "If the form has no submit button, then the implicit submission 
> mechanism must just submit the form element from the form element 
> itself." 
> http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#implicit-submission

This does not contradict what I wrote. It just says what to do if there IS 
an implicit submission mechanism, but there's no button at all.


On Sat, 24 Sep 2011, Ryosuke Niwa wrote:
> 
> WebKit's behavior is very confusing here. It does implicit submission in the
> following conditions:
> 
>    - One text fields
>    - One text field with one visible submit button
>    - Two text fields with one visible submit button
>    - Two text fields with one visibility:hidden submit button
>    - One text field with one display:none submit button
> 
> However, it doesn't submit when we have:
> 
>    - Two text fields

That's non-conforming currently.


>    - Two text fields with one display:none submit button

That's not really sensible, but it was technically within the spec's 
language. (You were allowed to not pick a default button if there was one 
to pick from but you didn't like it for some reason.) I've changed the 
spec to make this no longer allowed. The first button will now always be 
the default.


> Given that WebKit implicitly submits form even in the presence of a 
> visible submit button or an invisible submit button (visibility: hidden, 
> or display: none with exactly one text field), I don't see why we should 
> avoid implicit submission only when there are multiple form controls and 
> a display:none submit button.

Agreed.


On Sat, 24 Sep 2011, Ryosuke Niwa wrote:
> 
> IE9 does implicit submission in the following conditions:
> 
>    - One text field
>    - One text field with one visible submit button
>    - One text field with one display:none submit button
>    - Two text fields with one visible submit button
> 
> It does not do implicit submissio in the following conditions:
> 
>    - Two text fields
>    - Two text fields with one visibility:hidden submit button
>    - Two text fields with one display:none submit button
> 
> Basically, IE9 only does implicit submission when there is exactly one 
> text field (you can have checkbox, hidden, etc...) or there is a visible 
> button (i.e. not diplay: none nor visibility: hidden).

If you submit with one text field and no button, then you are required to 
also submit with two text fields and no button. So this is non-conforming.


> Firefox 5 does implicit submission in the following conditions:
> 
>    - One text field
>    - One text field with one visible submit button
>    - One text field with one display:none submit button
>    - Two text fields with one visible submit button
>    - Two text fields with one visibility:hidden submit button
>    - Two text fields with one display:none submit button
> 
> It does not do implicit submissio in the following conditions:
> 
>    - Two text fields
> 
> In summary, Firefox special cases one text field (can have checkbox, 
> hidden, etc...) like MSIE and requires a submit button with more than 
> two text fields regardless of presence of visibility: hidden or display: 
> none.

On Sun, 25 Sep 2011, Kaustubh Atrawalkar wrote:
>
> Opera - Does Implicit submission in following cases -
> * One text field
> * One text field with one visible submit button
> * One text field with one display:none submit button
> * Two text fields with one visible submit button
> * Two text fields with one visibility:hidden submit button
> * Two text fields with one display:none submit button
> 
> Only in following case it does not -
> * Two text fields

Those seem non-conforming for the same reason.


On Sun, 25 Sep 2011, Boris Zbarsky wrote:
> 
> Not doing that last is actually a requirement for web compat, last I 
> looked at this.

Do you have any links to pages that break if a form with more than one 
text field supports implicit submission?


> Furthermore, a requirement for web compat is that in the two-textfield 
> case the submission happen via triggering a click event on the default 
> submit element for the form and then allowing that to trigger submission 
> as it would normally (or not trigger it, if the page prevents its 
> default action, etc).  I expect this event-firing business is why IE has 
> any sort of dependency on styles for the submit button, and I would not 
> be surprised if that's why WebKit has it too.

The spec tried to say this, though it did so poorly. It now definitely 
says this.


> For the one-text-input case, as I recall IE does NOT click the default 
> submit, at least as of 2002; Gecko used to have that behavior but we 
> opted for more consistency.  So the current Gecko behavior is to submit 
> via clicking the default submit input if there is one, else to submit 
> only if there is only one text control (where the definition of "text 
> control" is especially interesting, since it of course includes controls 
> of unknown types, so as new form control types are added things get 
> _really_ exciting before browsers implement them).
> 
> Submitting forms with no submit on enter in a single text control is 
> also required for web compat, of course.
> 
> There is also the separate issue of _which_ controls enter triggers 
> submission in (e.g. it works in checkbox or radio in Gecko, iirc, but of 
> course not in textarea).
> 
> For those who want to mess with the spec for this behavior, 
> https://bugzilla.mozilla.org/show_bug.cgi?id=99920 and 
> https://bugzilla.mozilla.org/show_bug.cgi?id=109463 and 
> https://bugzilla.mozilla.org/show_bug.cgi?id=147850 are necessary (but 
> probably not sufficient) reading.

I read those bugs, but can't see the reason why submitting a form with two 
text fields and no buttons would break the Web. Can you elaborate?


On Sat, 24 Sep 2011, Glenn Maynard wrote:
> 
> Nothing in "4.10.22.2 Implicit submission" seems to allow implicit 
> submission to vary based on whether a submit button is displayed or 
> not...

Technically, if you have a button, you could arbitrarily pick the default 
from the buttons you have, including picking no button, and the spec put 
no limit on what you based the decision on.

I've now changed this since it allowed different behaviours unnecessarily.


> (It also explicitly says that if implicit submit is supported but 
> there's no submit button in the form, the implicit submit must still 
> happen.  That doesn't sound like it could be followed, since lots of 
> pages are probably depending on the absence of a submit button 
> suppressing implicit submit. That's just backwards-compatibility, not 
> platform conventions, though.)

Do you have any such pages to point to?


On Sat, 24 Sep 2011, Ryosuke Niwa wrote:
> 
> Why? From user's perspective, not having submit button, having a submit 
> button with display: none, having a submit button with visibility: 
> hidden all look the same.

The semantics of the page don't change though.

(Opacity:0.01 and margin-left:-100em would both also look the same, but 
presumably you don't think those shouldn't submit.)


On Sun, 25 Sep 2011, Ryosuke Niwa wrote:
> 
> Why is this authoring question? As an user, I'd like to know whether 
> pressing enter in my text field triggers implicit submission or not.

Whether it does or not should be based on the conventions of the platform.


On Sun, 25 Sep 2011, Ryosuke Niwa wrote:
> 
> I personally find implicit form submission to be annoying, and always wished
> I could disable it (also backspace triggering backward navigation).

Really? I've always found it annoying that I have to hunt for the submit 
button. I don't have to in Windows dialogs, why do I have to on Web pags 
in Windows browsers? Doesn't make any sense.


On Thu, 29 Sep 2011, Kaustubh Atrawalkar wrote:
>
> In case of single Input box and disabled (but visible button) forms 
> still gets submitted on implicit submission. This is again something 
> weird and happens in IE & Webkit but not in FF & opera. IMHO, the 
> implicit submission should have straight away algorithm -
> 
> 1) If submit button is there but not disabled implicit submission should
> happen on enter key press
> 2) If submit button is there and disabled implicit submission should not
> happen on enter key press
> 
> Both logic should be irrespective of number of input button OR 
> visibility of submit button.

The spec agrees with you. If there's a button, and it's the default, then 
if it is disabled the form won't submit. If there's a button and it's not 
the default, the form wouldn't submit either. So if there's a button and 
it's disabled, you should not be able to implicitly submit, per the spec.


On Fri, 9 Dec 2011, Ryosuke Niwa wrote:
>
> Given that both IE and WebKit have been disabling implicit form 
> submission for years when the button has display: none, I don't think we 
> can change our behavior here.

On Fri, 9 Dec 2011, Boris Zbarsky wrote:
> 
> Why, given that neither Gecko nor Opera have, and as far as I know have 
> gotten precisely 0 bug reports about that?

I agree with Boris here.

I've changed the spec to be clearer that CSS cannot be taken into account 
when determining the default. The default button is just always the first 
submit button in the form.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Tuesday, 21 February 2012 16:35:35 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:11 UTC