Bug 11681 - REGRESSION: Resetting a multiple-select control selects first item rather than none
: REGRESSION: Resetting a multiple-select control selects first item rather tha...
Status: RESOLVED FIXED
: WebKit
Forms
: 420+
: PC All
: P1 Normal
Assigned To:
:
: Regression
:
:
  Show dependency treegraph
 
Reported: 2006-11-22 14:13 PST by
Modified: 2006-12-05 02:36 PST (History)


Attachments
Checks for multiple-select before setting option on reset (1.12 KB, patch)
2006-11-22 14:32 PST, Kirby White
mitz: review-
Review Patch | Details | Formatted Diff | Diff
Adding testcase (3.37 KB, patch)
2006-11-27 17:45 PST, Kirby White
adele: review-
Review Patch | Details | Formatted Diff | Diff
Apply change to all listbox <select> controls (3.81 KB, patch)
2006-11-28 13:46 PST, Kirby White
ap: review+
Review Patch | Details | Formatted Diff | Diff


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2006-11-22 14:13:46 PST
Multiple-select form controls default to having nothing selected when the page is loaded, but when the form is reset with an <input type="reset"> or <button type="reset"> control they have the first item selected instead.
------- Comment #1 From 2006-11-22 14:32:25 PST -------
Created an attachment (id=11616) [details]
Checks for multiple-select before setting option on reset
------- Comment #2 From 2006-11-22 23:16:57 PST -------
(From update of attachment 11616 [details])
The code change looks good, but shouldn't the same logic apply also to single-choice listboxes (e.g. <select size="5">)? It would be nice to fix this case as well.

+        WARNING: NO TEST CASES ADDED OR CHANGED

You should indeed add a layout test.

r- due to the missing test.
------- Comment #3 From 2006-11-27 17:45:44 PST -------
Created an attachment (id=11647) [details]
Adding testcase

As I understand the spec, single-choice <select> controls with no "selected" option properly default to the first option when reset, whereas multiple-choice ones reset to empty.  That makes sense, at least to me, since otherwise the single-select's drop-down wouldn't have anything to show.
------- Comment #4 From 2006-11-27 21:59:27 PST -------
(In reply to comment #3)
> Created an attachment (id=11647) [edit] [details]
> Adding testcase
> 
> As I understand the spec, single-choice <select> controls with no "selected"
> option properly default to the first option when reset, whereas multiple-choice
> ones reset to empty.  That makes sense, at least to me, since otherwise the
> single-select's drop-down wouldn't have anything to show.
> 

My comment was referring to single-select list boxes, not drop-downs. The behavior of the former in WebKit and Firefox is that initially they have no option selected. Furthermore, in Firefox, resetting the form deselects all options. So I was suggesting that WebKit do the same to be consistent both with itself and with Firefox.
------- Comment #5 From 2006-11-27 22:56:11 PST -------
(From update of attachment 11647 [details])
I agree with Mitz's comments.  You can use usesMenuList(), and only set the selection if that is true, instead of just checking m_multiple.
------- Comment #6 From 2006-11-28 13:46:06 PST -------
Created an attachment (id=11653) [details]
Apply change to all listbox <select> controls

(In reply to comment #4)
> My comment was referring to single-select list boxes, not drop-downs.

Oh, of course.  Sorry, I misunderstood.  Here's the fix.
------- Comment #7 From 2006-12-05 01:35:22 PST -------
(From update of attachment 11653 [details])
r=me
------- Comment #8 From 2006-12-05 02:36:00 PST -------
Committed revision 18019. I corrected formatting of the test, as it used tabs.

This was a regression, marking as such.