Commit 1f5d3318 authored by Anastasia Helfinstein's avatar Anastasia Helfinstein Committed by Commit Bot

[Switch Access] Reset keyboard nodes when invalidated

Fixes a bug where pressing shift rendered most of the keyboard
unreachable by rebuilding all of the keyboard nodes.

As a side effect, causes the focus to jump back to the beginning of the
keyboard when shift is engaged or disengaged.

AX-Relnotes: n/a.
Fixed: 1126923
Change-Id: I74cbf35c8e967aed2d7ece19378264aa1b6e9b0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419387
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809118}
parent 6e7384d4
...@@ -32,6 +32,14 @@ class NavigationManager { ...@@ -32,6 +32,14 @@ class NavigationManager {
// =============== Static Methods ============== // =============== Static Methods ==============
/**
* @param {!SAChildNode} node
* @return {boolean}
*/
static currentGroupHasChild(node) {
return NavigationManager.instance.group_.children.includes(node);
}
/** /**
* Enters |this.node_|. * Enters |this.node_|.
*/ */
...@@ -50,8 +58,6 @@ class NavigationManager { ...@@ -50,8 +58,6 @@ class NavigationManager {
/** /**
* Puts focus on the virtual keyboard, if the current node is a text input. * Puts focus on the virtual keyboard, if the current node is a text input.
* TODO(crbug/946190): Handle the case where the user has not enabled the
* onscreen keyboard.
*/ */
static enterKeyboard() { static enterKeyboard() {
const navigator = NavigationManager.instance; const navigator = NavigationManager.instance;
......
...@@ -34,6 +34,23 @@ class KeyboardNode extends BasicNode { ...@@ -34,6 +34,23 @@ class KeyboardNode extends BasicNode {
return false; return false;
} }
/** @override */
isValidAndVisible() {
if (super.isValidAndVisible()) {
return true;
}
if (!KeyboardNode.resetting &&
NavigationManager.currentGroupHasChild(this)) {
// TODO(crbug/1130773): move this code to another location, if possible
KeyboardNode.resetting = true;
KeyboardRootNode.ignoreNextExit_ = true;
NavigationManager.exitKeyboard();
NavigationManager.enterKeyboard();
}
return false;
}
/** @override */ /** @override */
performAction(action) { performAction(action) {
if (action !== SwitchAccessMenuAction.SELECT) { if (action !== SwitchAccessMenuAction.SELECT) {
...@@ -66,6 +83,7 @@ class KeyboardRootNode extends BasicRootNode { ...@@ -66,6 +83,7 @@ class KeyboardRootNode extends BasicRootNode {
*/ */
constructor(groupNode) { constructor(groupNode) {
super(groupNode); super(groupNode);
KeyboardNode.resetting = false;
} }
// ================= General methods ================= // ================= General methods =================
...@@ -80,6 +98,11 @@ class KeyboardRootNode extends BasicRootNode { ...@@ -80,6 +98,11 @@ class KeyboardRootNode extends BasicRootNode {
/** @override */ /** @override */
onExit() { onExit() {
if (KeyboardRootNode.ignoreNextExit_) {
KeyboardRootNode.ignoreNextExit_ = false;
return;
}
// If the keyboard is currently visible, ignore the corresponding // If the keyboard is currently visible, ignore the corresponding
// state change. // state change.
if (KeyboardRootNode.isVisible_) { if (KeyboardRootNode.isVisible_) {
......
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