Bug 11681 - REGRESSION: Resetting a multiple-select control selects first item rather than none
Summary: REGRESSION: Resetting a multiple-select control selects first item rather tha...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 420+
Hardware: PC All
: P1 Normal
Assignee: Nobody
URL:
Keywords: Regression
Depends on:
Blocks:
 
Reported: 2006-11-22 14:13 PST by Kirby White
Modified: 2006-12-05 02:36 PST (History)
1 user (show)

See Also:


Attachments
Checks for multiple-select before setting option on reset (1.12 KB, patch)
2006-11-22 14:32 PST, Kirby White
mitz: review-
Details | Formatted Diff | Diff
Adding testcase (3.37 KB, patch)
2006-11-27 17:45 PST, Kirby White
adele: review-
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+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kirby White 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 Kirby White 2006-11-22 14:32:25 PST
Created attachment 11616 [details]
Checks for multiple-select before setting option on reset
Comment 2 mitz 2006-11-22 23:16:57 PST
Comment on attachment 11616 [details]
Checks for multiple-select before setting option on reset

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 Kirby White 2006-11-27 17:45:44 PST
Created attachment 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 mitz 2006-11-27 21:59:27 PST
(In reply to comment #3)
> Created an attachment (id=11647) [edit]
> 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 Adele Peterson 2006-11-27 22:56:11 PST
Comment on attachment 11647 [details]
Adding testcase

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 Kirby White 2006-11-28 13:46:06 PST
Created attachment 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 Alexey Proskuryakov 2006-12-05 01:35:22 PST
Comment on attachment 11653 [details]
Apply change to all listbox <select> controls

r=me
Comment 8 Alexey Proskuryakov 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.