Bug 1539984 - pass along whether a focus change was tripped by a keypress to ensure :-moz-focusring works as designed, r=Jamie

Differential Revision: https://phabricator.services.mozilla.com/D27874

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2019-04-22 23:41:56 +00:00
Родитель bfe578d84d
Коммит 539daeb738
2 изменённых файлов: 10 добавлений и 5 удалений

Просмотреть файл

@ -1499,7 +1499,7 @@ var PanelView = class extends AssociatedToNode {
&& walker.nextNode()) { && walker.nextNode()) {
this.selectedElement = walker.currentNode; this.selectedElement = walker.currentNode;
} }
this.focusSelectedElement(); this.focusSelectedElement(/* byKey */ true);
} }
/** /**
@ -1514,7 +1514,7 @@ var PanelView = class extends AssociatedToNode {
this._arrowNavigableWalker : this._tabNavigableWalker; this._arrowNavigableWalker : this._tabNavigableWalker;
walker.currentNode = walker.root; walker.currentNode = walker.root;
this.selectedElement = walker.lastChild(); this.selectedElement = walker.lastChild();
this.focusSelectedElement(); this.focusSelectedElement(/* byKey */ true);
} }
/** /**
@ -1607,7 +1607,7 @@ var PanelView = class extends AssociatedToNode {
let isDown = (keyCode == "ArrowDown") || let isDown = (keyCode == "ArrowDown") ||
(keyCode == "Tab" && !event.shiftKey); (keyCode == "Tab" && !event.shiftKey);
let button = this.moveSelection(isDown, keyCode != "Tab"); let button = this.moveSelection(isDown, keyCode != "Tab");
button.focus(); Services.focus.setFocus(button, Services.focus.FLAG_BYKEY);
break; break;
} }
case "Home": case "Home":
@ -1670,11 +1670,15 @@ var PanelView = class extends AssociatedToNode {
/** /**
* Focus the last selected element in the view, if any. * Focus the last selected element in the view, if any.
*
* @param byKey {Boolean} whether focus was moved by the user pressing a key.
* Needed to ensure we show focus styles in the right cases.
*/ */
focusSelectedElement() { focusSelectedElement(byKey = false) {
let selected = this.selectedElement; let selected = this.selectedElement;
if (selected) { if (selected) {
selected.focus(); let flag = byKey ? "FLAG_BYKEY" : "FLAG_BYELEMENTFOCUS";
Services.focus.setFocus(selected, Services.focus[flag]);
} }
} }

Просмотреть файл

@ -370,6 +370,7 @@ description#identity-popup-content-verifier,
.identity-popup-content-blocking-category:hover { .identity-popup-content-blocking-category:hover {
border-radius: 2px; border-radius: 2px;
background-color: var(--arrowpanel-dimmed); background-color: var(--arrowpanel-dimmed);
outline: none;
} }
.identity-popup-content-blocking-category:hover:active { .identity-popup-content-blocking-category:hover:active {