Selecting OptGroup label does not deselect selected item

OptGroup since it is a label, if selected should not deselect selected item. In updateStateSelected, it is checked if optGroup, no UI changes are triggered.

R=keishi1, tkent
BUG=342189
TEST=On selecting optGroup label, selectedIndex should not be deselected.

Review URL: https://codereview.chromium.org/204433002

git-svn-id: svn://svn.chromium.org/blink/trunk@171470 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 63634776
......@@ -7,6 +7,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Click enabled option
PASS $("listbox").selectedIndex is 1
Click on optgroup, should not deselect selectedIndex
PASS $("listbox").selectedIndex is 1
Click disabled option - doesn't change selectedIndex
PASS $("listbox").selectedIndex is 1
......
......@@ -62,6 +62,12 @@ function test()
eventSender.mouseUp();
shouldBe('$("listbox").selectedIndex', '1');
debug("\nClick on optgroup, should not deselect selectedIndex");
mouseMoveToIndexInListbox(0, 'listbox'); // Select on optgroup
eventSender.mouseDown();
eventSender.mouseUp();
shouldBe('$("listbox").selectedIndex', '1');
debug("\nClick disabled option - doesn't change selectedIndex");
mouseMoveToIndexInListbox(5 + 2, 'listbox'); // +2 for optgroup's
eventSender.mouseDown();
......
......@@ -7,6 +7,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Click enabled option
PASS $("listbox").selectedIndex is 1
Click on optgroup, should not deselect selectedIndex
PASS $("listbox").selectedIndex is 1
Click disabled option - doesn't change selectedIndex
PASS $("listbox").selectedIndex is 1
......
......@@ -1285,6 +1285,11 @@ void HTMLSelectElement::updateSelectedState(int listIndex, bool multi, bool shif
{
ASSERT(listIndex >= 0);
HTMLElement* clickedElement = listItems()[listIndex];
ASSERT(clickedElement);
if (isHTMLOptGroupElement(clickedElement))
return;
// Save the selection so it can be compared to the new selection when
// dispatching change events during mouseup, or after autoscroll finishes.
saveLastSelection();
......@@ -1294,8 +1299,6 @@ void HTMLSelectElement::updateSelectedState(int listIndex, bool multi, bool shif
bool shiftSelect = m_multiple && shift;
bool multiSelect = m_multiple && multi && !shift;
HTMLElement* clickedElement = listItems()[listIndex];
ASSERT(clickedElement);
if (isHTMLOptionElement(*clickedElement)) {
// Keep track of whether an active selection (like during drag
// selection), should select or deselect.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment