Bug 1378016 - Fix keyboard navigation and selection on 'recent bookmarks'. r=Gijs

MozReview-Commit-ID: GJ7vRPz8zuo

--HG--
extra : rebase_source : b8a212cd174f81994e3cdb5adc4226b5dfc531d3
This commit is contained in:
Erica Wright 2017-07-31 09:47:19 -04:00
parent 0be9924b76
commit e2a35da326

View File

@ -1022,12 +1022,10 @@ this.PanelMultiView = class {
buttons = navMap.buttons = this._getNavigableElements(view);
// Set the 'tabindex' attribute on the buttons to make sure they're focussable.
for (let button of buttons) {
if (button.classList.contains("subviewbutton-back"))
continue;
// If we've been here before, forget about it!
if (button.hasAttribute("tabindex"))
break;
button.setAttribute("tabindex", 0);
if (!button.classList.contains("subviewbutton-back") &&
!button.hasAttribute("tabindex")) {
button.setAttribute("tabindex", 0);
}
}
}
if (!buttons.length)
@ -1078,14 +1076,21 @@ this.PanelMultiView = class {
break;
// Fall-through...
}
case "Space":
case "Enter": {
let button = buttons[navMap.selected];
if (!button)
break;
stop();
// Unfortunately, 'tabindex' doesn't not execute the default action, so
// Unfortunately, 'tabindex' doesn't execute the default action, so
// we explicitly do this here.
button.click();
// We are sending a command event and then a click event.
// This is done in order to mimic a "real" mouse click event.
// The command event executes the action, then the click event closes the menu.
button.doCommand();
let clickEvent = new event.target.ownerGlobal.MouseEvent("click", {"bubbles": true});
button.dispatchEvent(clickEvent);
break;
}
}