Open Bug 987143 Opened 10 years ago Updated 2 years ago

Select tag with required attribute and a disabled option selects an option automatically while not showing it selected.

Categories

(Core :: Layout: Form Controls, defect)

28 Branch
x86
Windows 7
defect

Tracking

()

UNCONFIRMED

People

(Reporter: linotechie, Unassigned)

References

(Depends on 1 open bug)

Details

Attachments

(2 files, 1 obsolete file)

Steps to reproduce:

Render in a form a select tag in Fx such as the following:

<select name='example' size='1' required='required'>
<option disabled='disabled'>Select an option</option>
<option value='a'>Option A</option>
<option value='b'>Option B</option>
</select>

Now, in the rendered page, click this tag and hover over an option (say Option B) but do not click to select it.

Actual result:

The selected choice (as seen by the user) will remain the first option ("Select an option") but actually, the browser has, somehow on its own, selected Option B, which can be confirmed by submitting the form.

Expected result:

The option seen by the user should be the one sent by the browser on submitting the form.
Sorry, forgot to add the attribute selected='selected' to the first option (the disabled one). Please assume that too, in the above code.
Severity: major → normal
Component: General → Layout: Form Controls
Product: Firefox → Core
Attached file testcase.html (obsolete) —
Yeah that. Thank you YF (Yang).

This should be a major bug because an unwanted option might be submitted unbeknown to the user, which would result in confusion at best, but also maybe an unwanted order/shipment or selection (such as a wrong tld while purchasing a domain name).

This bug does not exist in Chrome.
It would be useful to have a testcase that shows whether the bug is present (i.e., shows what the value of the control is).
Attached file testcase.html
Attachment #8409668 - Attachment is obsolete: true
(In reply to YF (Yang) from comment #5)
> Created attachment 8409871 [details]
> testcase.html

I can reproduce the disabled items are selected and no grizzly at initially.

But if mouse move to rest items, the disabled item can't be selected again.
However, if click on empty space at this time, the disabled item be afresh selected, but seem once occurrence any event for it, the selected jump to the second item.
The next question is: what does http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-select-element say is supposed to happen when the initially-selected option is disabled?
Comment 4: It would be useful to have a testcase that shows whether the bug is present (i.e., shows what the value of the control is).

Below is a little snippet that uses Javascript to alert with the selected value. (I'm also creating an attachment containing this code.)

Usage: On the rendered page, hover over an (enabled) option (do not click on it). Then click somewhere outside to make the options list collapse. The disabled option stays the selected one (alright up to this point). Now click on the page one more time to fire the Javascript event fire, and it will pop up an alert with the value of the selected option (which would be the option you had hovered over last).

Code:

<select required='required' onChange='alert(this.options[this.selectedIndex].value)'>
	<option disabled='disabled' selected='selected'>Select an option</option>
	<option value='a'>Option A</option>
	<option value='b'>Option B</option>
</select>
@Comment 9

In the 8th comment of that bug, it is mentioned that (square brackets mine):

"the option shown in the select is not changed [same as this bug], and the option that will be sent via a form submission is not changed [different; the hovered option does get sent in this bug], and javascript change events aren't fired [different; they are fired in this bug], but the 'selected index' is changing"

So the two bugs are a bit different but someone more experienced can decide if they're duplicates.
Also, in that bug, when the mouse has clicked outside, the combo box control regains its correct value, while the combo box in this bug does not (it retains the erroneous value).
Right, I don't think it's a duplicate.  I just suspect that issue is contributing to this one in the case when the initially selected option is disabled, because it can't get reselected when the code tries to do that.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: