Bug 1782456 - Move unified extensions context menu to main popupset. r=rpl,Gijs

I noticed some missing context menu style when loading the context menu
from our own viewcache, which explains the difference between primary
and secondary button click. Not sure ecavtly what was missing as the
styles are all over the place.

The menu item actually works, the actions are called and for
checkbox-like menu items, the `checked` attribute is correctly set in
the "HTML". Also it looked like sub-menus weren't affected (e.g. Tree
Style Tab didn't have any issue).

While investigating, I also noticed that most (if not all) `menupopup`
elements are declared in the main popupset, so I tried to move the
unified extensions context menu to this main popupset and lazy-load the
l10n strings (similar to the toolbar context menu [1]).

That fixed the bug.

[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1609556

Differential Revision: https://phabricator.services.mozilla.com/D153330
This commit is contained in:
William Durand
2022-08-02 13:24:28 +00:00
parent 2304caa49c
commit 9ea8c792f2
4 changed files with 40 additions and 20 deletions

View File

@@ -1350,11 +1350,17 @@ var gUnifiedExtensions = {
this._listView.addEventListener("ViewShowing", this);
this._listView.addEventListener("ViewHiding", this);
// Load context menu popup.
const template = document.getElementById("unified-extensions-template");
if (template) {
template.replaceWith(template.content);
}
// Lazy-load the l10n strings.
document
.getElementById("unified-extensions-context-menu")
.querySelectorAll("[data-lazy-l10n-id]")
.forEach(el => {
el.setAttribute(
"data-l10n-id",
el.getAttribute("data-lazy-l10n-id")
);
el.removeAttribute("data-lazy-l10n-id");
});
}
if (this._button.open) {