Skip to content

Commit 45fa9d1

Browse files
SELECT: Fix deselection behavior on leaving the "multiple" mode
If - the SELECT switched from the "multiple" mode, - it had two or more selected OPTIONs, and - last_on_change_option_ was the first selected OPTION, we missed to deselect OPTIONs other than the first one due to the fast path of DeselectItemsWithoutValidation(). This CL clears last_on_change_option_ before calling DeselectItemsWithoutValidation(). Bug: 1245443 Change-Id: Ib9cc4a4770d99ed6782edc73fd8ff1fcb3d8738b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3205138 Auto-Submit: Kent Tamura <tkent@chromium.org> Reviewed-by: Aleks Totic <atotic@chromium.org> Commit-Queue: Kent Tamura <tkent@chromium.org> Cr-Commit-Position: refs/heads/main@{#928412}
1 parent f5c6954 commit 45fa9d1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

html/semantics/forms/the-select-element/select-multiple.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,16 @@
3333
assert_true(select.options[1].selected, "second option should be selected.");
3434

3535
}, "multiple selected options exist, one set from script");
36+
37+
// crbug.com/1245443
38+
test(() => {
39+
let select = document.createElement("select");
40+
select.length = 4;
41+
let o1 = select.options.item(1);
42+
select.multiple = true;
43+
select.selectedIndex = 2;
44+
o1.selected = true;
45+
select.multiple = false;
46+
assert_equals(select.selectedOptions.length, 1);
47+
}, "Removing multiple attribute reduces the number of selected OPTIONs to 1");
3648
</script>

0 commit comments

Comments
 (0)