From 68aff7b23e6c412f70b7a2815b8103f9c0a448ae Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Fri, 2 May 2025 16:03:15 -0400 Subject: [PATCH] Hide leftover popups when switching tabs (#5251) --- chrome/content/zotero/tabs.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/chrome/content/zotero/tabs.js b/chrome/content/zotero/tabs.js index 5c5139d0e2..e18f572649 100644 --- a/chrome/content/zotero/tabs.js +++ b/chrome/content/zotero/tabs.js @@ -495,6 +495,19 @@ var Zotero_Tabs = new function () { selectedTab.timeUnselected = Zotero.Date.getUnixTimestamp(); } } + + // If the current tab left behind open popups, they'll remain as empty + // ghosts in the new tab. Close them. + if (this.deck.selectedPanel) { + try { + for (let popup of this.deck.selectedPanel.querySelectorAll('panel, menupopup')) { + popup.hidePopup(); + } + } + catch (e) { + Zotero.logError(e); + } + } // If the last focus data was recorded for a different item, discard it if (!this._focusOptions.itemID || this._focusOptions.itemID != tab?.data?.itemID) {