Commit 7f2cfc73 authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

An accessible click on a menu list option should toggle menu list popup

The options in an HTML select element are present in the
accessibility tree even when the popup is not visible. As a
result it's possible for AT such as ChromeVox to fire a click
event on an option. However, since the popup is collapsed, the
expected behavior is for the menu to pop open - then clicking it
again should close it.

This wasn't implemented before because most AT only sends the
click event to the <select> element when it's collapsed.

Bug: 1046087
Change-Id: Ic110efc771490035e24041362211dc5c61585248
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2025323Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736123}
parent 74140555
......@@ -141,6 +141,22 @@ AccessibilitySelectedState AXMenuListOption::IsSelected() const {
: kSelectedStateFalse);
}
bool AXMenuListOption::OnNativeClickAction() {
if (!element_)
return false;
// Clicking on an option within a menu list should first select that item,
// then toggle whether the menu list is showing.
element_->SetSelected(true);
// Calling OnNativeClickAction on the parent select element will toggle
// it open or closed.
if (ParentObject() && ParentObject()->IsMenuListPopup())
return ParentObject()->OnNativeClickAction();
return AXMockObject::OnNativeClickAction();
}
bool AXMenuListOption::OnNativeSetSelectedAction(bool b) {
if (!element_ || !CanSetSelectedAttribute())
return false;
......
......@@ -59,6 +59,7 @@ class AXMenuListOption final : public AXMockObject {
bool IsVisible() const override;
bool IsOffScreen() const override;
AccessibilitySelectedState IsSelected() const override;
bool OnNativeClickAction() override;
bool OnNativeSetSelectedAction(bool) override;
void GetRelativeBounds(AXObject** out_container,
......
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