Bug 881937 - focus the first focusable item, r=mconley

This commit is contained in:
Gijs Kruitbosch 2013-07-19 15:30:03 +02:00
parent 8cd04017d1
commit f32fda67ec
2 changed files with 13 additions and 2 deletions

View File

@ -114,7 +114,7 @@
<command id="Social:FocusChat" oncommand="SocialChatBar.focus();" hidden="true" disabled="true"/>
<command id="Social:Toggle" oncommand="Social.toggle();" hidden="true"/>
<command id="Social:Addons" oncommand="BrowserOpenAddonsMgr('addons://list/service');"/>
<command id="MenuPanel:Toggle" oncommand="PanelUI.toggle();"/>
<command id="MenuPanel:Toggle" oncommand="PanelUI.toggle(event);"/>
</commandset>
<commandset id="placesCommands">

View File

@ -84,10 +84,21 @@ const PanelUI = {
updateEditUIVisibility();
}
let anchor = aEvent ? aEvent.target : this.menuButton;
let anchor;
if (aEvent.type == "command") {
anchor = this.menuButton;
} else {
anchor = aEvent.target;
}
let iconAnchor =
document.getAnonymousElementByAttribute(anchor, "class",
"toolbarbutton-icon");
// Only focus the panel if it's opened using the keyboard, so that
// cut/copy/paste buttons will work for mouse users.
let keyboardOpened = aEvent.sourceEvent &&
aEvent.sourceEvent.target.localName == "key";
this.panel.setAttribute("noautofocus", !keyboardOpened);
this.panel.openPopup(iconAnchor || anchor, "bottomcenter topright");
}
},