Commit 190aba0a authored by Anastasia Helfinstein's avatar Anastasia Helfinstein Committed by Commit Bot

[Switch Access] Jump to the menu in all cases

Fixes a bug where the menu is not being entered sometimes.

AX-Relnotes: n/a.
Bug: N/A
Change-Id: Ifeee180eda2cf681672392bde7e9c032dd86c9e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2228557
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775315}
parent 128a3a37
......@@ -135,20 +135,21 @@ class MenuManager {
chrome.accessibilityPrivate.SwitchAccessBubble.MENU, true /* show */,
location, actions);
this.findMenuAutomationNode_();
this.isMenuOpen_ = true;
this.findAndJumpToMenuAutomationNode_();
this.displayedActions_ = actions;
this.displayedLocation_ = location;
}
/**
* Searches the automation tree to find the node for the Switch Access menu.
* If we've already found a node, and it's still valid, then we do nothing.
* If we've already found a node, and it's still valid, then jump to that
* node.
* @private
*/
findMenuAutomationNode_() {
if (this.hasValidMenuAutomationNode_()) {
return;
findAndJumpToMenuAutomationNode_() {
if (this.hasValidMenuAutomationNode_() && this.menuAutomationNode_) {
this.jumpToMenuAutomationNode_(this.menuAutomationNode_);
}
SwitchAccess.findNodeMatchingPredicate(
MenuManager.isSwitchAccessMenuNode_,
......@@ -186,16 +187,24 @@ class MenuManager {
* @private
*/
jumpToMenuAutomationNode_(node) {
// If the menu hasn't loaded, wait for that before jumping.
if (!this.isMenuOpen_) {
return;
}
// If the menu hasn't fully loaded, wait for that before jumping.
if (node.children.length < 1 ||
node.firstChild.state[chrome.automation.StateType.OFFSCREEN]) {
const callback = () => {
node.removeEventListener(
chrome.automation.EventType.CHILDREN_CHANGED, callback, false);
node.removeEventListener(
chrome.automation.EventType.LOCATION_CHANGED, callback, false);
this.jumpToMenuAutomationNode_(node);
};
node.addEventListener(
chrome.automation.EventType.CHILDREN_CHANGED, callback, false);
node.addEventListener(
chrome.automation.EventType.LOCATION_CHANGED, callback, false);
return;
}
......
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