Skip to content

Commit

Permalink
SELECT: Fix deselection behavior on leaving the "multiple" mode
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Aleks Totic <[email protected]>
Commit-Queue: Kent Tamura <[email protected]>
Cr-Commit-Position: refs/heads/main@{#928412}
  • Loading branch information
tkent-google authored and Gabisampaio committed Nov 18, 2021
1 parent 0a16c15 commit bcbc1d2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions html/semantics/forms/the-select-element/select-multiple.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,16 @@
assert_true(select.options[1].selected, "second option should be selected.");

}, "multiple selected options exist, one set from script");

// crbug.com/1245443
test(() => {
let select = document.createElement("select");
select.length = 4;
let o1 = select.options.item(1);
select.multiple = true;
select.selectedIndex = 2;
o1.selected = true;
select.multiple = false;
assert_equals(select.selectedOptions.length, 1);
}, "Removing multiple attribute reduces the number of selected OPTIONs to 1");
</script>

0 comments on commit bcbc1d2

Please sign in to comment.