Commit d10b391b authored by John Lee's avatar John Lee Committed by Chromium LUCI CQ

WebUI: Move focus to first item in menu if focus moves from outside tab

Bug: 1164838
Change-Id: Ife2d3e970b9ab70bf1fd488f47eb9bf1bf516a4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2622732Reviewed-by: default avatardpapad <dpapad@chromium.org>
Commit-Queue: John Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842709}
parent a814d87a
......@@ -46,9 +46,10 @@ export class CrMenuSelector extends HTMLElement {
// If the focus was moved by keyboard and is coming in from a relatedTarget
// that is not within this menu, move the focus to the first menu item. This
// ensures that the first menu item is always the first focused item when
// focusing into the menu.
// focusing into the menu. A null relatedTarget means the focus was moved
// from outside the WebContents.
const focusMovedWithKeyboard = this.focusOutlineManager_.visible;
const focusMovedFromOutside = e.relatedTarget &&
const focusMovedFromOutside = e.relatedTarget === null ||
!this.contains(/** @type {!HTMLElement} */ (e.relatedTarget));
if (focusMovedWithKeyboard && focusMovedFromOutside) {
this.getItems_()[0].focus();
......
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