Bug 1724668 - Ensure Pocket panel closes if location changes with locationSpecific CustomizableUI prop. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D122278
This commit is contained in:
Scott
2021-08-20 16:54:00 +00:00
parent 85223b8815
commit 6b8ab0fe63
8 changed files with 219 additions and 40 deletions

View File

@@ -2018,16 +2018,6 @@ var gBrowserInit = {
PanicButtonNotifier.init();
});
gBrowser.tabContainer.addEventListener("TabSelect", function() {
for (let panel of document.querySelectorAll(
"panel[tabspecific='true']"
)) {
if (panel.state == "open") {
panel.hidePopup();
}
}
});
if (BrowserHandler.kiosk) {
// We don't modify popup windows for kiosk mode
if (!gURLBar.readOnly) {
@@ -5422,6 +5412,25 @@ var XULBrowserWindow = {
);
}
let closeOpenPanels = selector => {
for (let panel of document.querySelectorAll(selector)) {
if (panel.state == "open") {
panel.hidePopup();
}
}
};
// If the location is changed due to switching tabs,
// ensure we close any open tabspecific panels.
if (aIsSimulated) {
closeOpenPanels("panel[tabspecific='true']");
}
// Ensure we close any remaining open locationspecific panels
if (!isSameDocument) {
closeOpenPanels("panel[locationspecific='true']");
}
// About pages other than about:reader are not currently supported by
// screenshots (see Bug 1620992).
Services.obs.notifyObservers(