Commit b99637e9 authored by Akihiro Ota's avatar Akihiro Ota Committed by Commit Bot

ChromeVox: Ensure Search menu scrolls items into view, if offscreen.

Bug: 1058472
Change-Id: I66f4c77f02f2486fe151bfbd4142015798a9b2d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087493Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747309}
parent a47fc84f
......@@ -454,6 +454,19 @@ PanelSearchMenu = class extends PanelMenu {
const item = this.items_[this.activeIndex_];
this.searchBar.setAttribute('aria-activedescendant', item.element.id);
item.element.classList.add('active');
// Scroll item into view, if necessary. Only check y-axis.
const itemBounds = item.element.getBoundingClientRect();
const menuBarBounds = this.menuBarItemElement.getBoundingClientRect();
const topThreshold = menuBarBounds.bottom;
const bottomThreshold = window.innerHeight;
if (itemBounds.bottom > bottomThreshold) {
// Item is too far down, so align to top.
item.element.scrollIntoView(true /* alignToTop */);
} else if (itemBounds.top < topThreshold) {
// Item is too far up, so align to bottom.
item.element.scrollIntoView(false /* alignToTop */);
}
}
/** @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