Commit 58bfbaa1 authored by Akihiro Ota's avatar Akihiro Ota Committed by Commit Bot

ChromeVox: Announce when no results are available in the search menu.

Before this change:
If a user tried to search the menus and no items matched their query,
'no items' was displayed visually, but not communicated verbally.

After this change:
ChromeVox announces when no items match their search query. This change
also makes a small UX enhancement; if there is no query upon activating
the menu, then we should clear the previous contents of the menu.

Bug: 1056282
Change-Id: I5563f45850c4d8377090558e7a637bf209165458
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2074813Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745106}
parent 4ed2234c
......@@ -426,6 +426,12 @@ PanelSearchMenu = class extends PanelMenu {
/** @override */
activate(activateFirstItem) {
PanelMenu.prototype.activate.call(this, false);
if (this.searchBar.value === '') {
this.clear();
}
if (this.items_.length > 0) {
this.activateItem(this.activeIndex_);
}
this.searchBar.focus();
}
......@@ -450,6 +456,16 @@ PanelSearchMenu = class extends PanelMenu {
item.element.classList.add('active');
}
/** @override */
addMenuItem(
menuItemTitle, menuItemShortcut, menuItemBraille, gesture, callback,
opt_id) {
this.searchResultCounter_ += 1;
return PanelMenu.prototype.addMenuItem.call(
this, menuItemTitle, menuItemShortcut, menuItemBraille, gesture,
callback, 'result-number-' + this.searchResultCounter_.toString());
}
/** @override */
advanceItemBy(delta) {
this.activateItem(this.activeIndex_ + delta);
......@@ -464,6 +480,7 @@ PanelSearchMenu = class extends PanelMenu {
while (this.menuElement.children.length !== 0) {
this.menuElement.removeChild(this.menuElement.firstChild);
}
this.searchBar.setAttribute('aria-activedescendant', '');
}
/**
......@@ -472,11 +489,9 @@ PanelSearchMenu = class extends PanelMenu {
* @return {!PanelMenuItem} The menu item that was just created.
*/
copyAndAddMenuItem(item) {
this.searchResultCounter_ = this.searchResultCounter_ + 1;
return this.addMenuItem(
item.menuItemTitle, item.menuItemShortcut, item.menuItemBraille,
item.gesture, item.callback,
'result-number-' + this.searchResultCounter_.toString());
item.gesture, item.callback);
}
/** @override */
......
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