зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1658103 - Fix lazy translation of tab context menu. r=dao
The tab context menu is designed to not be translated until the user interacts with the tab strip in some way. However, the tab context menu is now shared between the tab strip and the "all tabs" panel. So, it's possible to open the tab context menu without interacting with the tab strip. This results in the context menu being opened before it is translated, so the user sees an essentially blank menu. Resolve this by adding to the all tabs panel an extra initialization step that will automatically translate the tab context menu. Differential Revision: https://phabricator.services.mozilla.com/D142850
This commit is contained in:
Родитель
56dd1d6854
Коммит
aa61f3c263
|
@ -6128,18 +6128,7 @@
|
|||
});
|
||||
|
||||
let tabContextFTLInserter = () => {
|
||||
MozXULElement.insertFTLIfNeeded("browser/tabContextMenu.ftl");
|
||||
// Un-lazify the l10n-ids now that the FTL file has been inserted.
|
||||
document
|
||||
.getElementById("tabContextMenu")
|
||||
.querySelectorAll("[data-lazy-l10n-id]")
|
||||
.forEach(el => {
|
||||
el.setAttribute(
|
||||
"data-l10n-id",
|
||||
el.getAttribute("data-lazy-l10n-id")
|
||||
);
|
||||
el.removeAttribute("data-lazy-l10n-id");
|
||||
});
|
||||
this.translateTabContextMenu();
|
||||
this.tabContainer.removeEventListener(
|
||||
"contextmenu",
|
||||
tabContextFTLInserter,
|
||||
|
@ -6291,6 +6280,22 @@
|
|||
});
|
||||
},
|
||||
|
||||
translateTabContextMenu() {
|
||||
if (this._tabContextMenuTranslated) {
|
||||
return;
|
||||
}
|
||||
MozXULElement.insertFTLIfNeeded("browser/tabContextMenu.ftl");
|
||||
// Un-lazify the l10n-ids now that the FTL file has been inserted.
|
||||
document
|
||||
.getElementById("tabContextMenu")
|
||||
.querySelectorAll("[data-lazy-l10n-id]")
|
||||
.forEach(el => {
|
||||
el.setAttribute("data-l10n-id", el.getAttribute("data-lazy-l10n-id"));
|
||||
el.removeAttribute("data-lazy-l10n-id");
|
||||
});
|
||||
this._tabContextMenuTranslated = true;
|
||||
},
|
||||
|
||||
setSuccessor(aTab, successorTab) {
|
||||
if (aTab.ownerGlobal != window) {
|
||||
throw new Error("Cannot set the successor of another window's tab");
|
||||
|
|
|
@ -199,6 +199,7 @@ class TabsPanel extends TabsListBase {
|
|||
if (!this.listenersRegistered && event.target == this.view) {
|
||||
this.panelMultiView = this.view.panelMultiView;
|
||||
this._populate(event);
|
||||
this.gBrowser.translateTabContextMenu();
|
||||
}
|
||||
break;
|
||||
case "command":
|
||||
|
|
Загрузка…
Ссылка в новой задаче