mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
5bada183cb
PanelMultiView adds the keydown handler on the window so that it handles key presses when a panel appears but doesn't get focus, as happens when a button to open a panel is clicked with the mouse. However, this means the listener is on an ancestor of the panel, which means that handlers such as ToolbarKeyboardNavigator are deeper in the tree. Previously, PanelMultiView used a bubbling (default) listener. This meant that ToolbarKeyboardNavigator handled the event first, causing it to interfere when a panel opened within the toolbar; e.g. the Library menu. To fix this, use a capturing listener for PanelMultiView so it gets the event first. Differential Revision: https://phabricator.services.mozilla.com/D24848 --HG-- extra : moz-landing-system : lando
18 lines
587 B
JavaScript
18 lines
587 B
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Force focus to an element that isn't focusable.
|
|
* Toolbar buttons aren't focusable because if they were, clicking them would
|
|
* focus them, which is undesirable. Therefore, they're only made focusable
|
|
* when a user is navigating with the keyboard. This function forces focus as
|
|
* is done during toolbar keyboard navigation.
|
|
*/
|
|
function forceFocus(aElem) {
|
|
aElem.setAttribute("tabindex", "-1");
|
|
aElem.focus();
|
|
aElem.removeAttribute("tabindex");
|
|
}
|