From 9c1af8e61ca9db604d2a3781e64c567ba8a8a0de Mon Sep 17 00:00:00 2001 From: Ramon Mi Date: Fri, 27 Mar 2026 21:25:21 +0800 Subject: [PATCH] fix(notes): prevent unloaded note tabs from opening as windows on shutdown Fix an issue where closing Zotero incorrectly opens notes as window if `note-unloaded` tabs exist after the currently selected tab. Previously, if Note A was opened as a tab and focus switched to a preceding tab, restarting Zotero would load Note A as `note-unloaded`. Upon closing Zotero again, Note A would incorrectly spawn as a separate window instead of closing with the main pane. This fix ensures that `note-unloaded` type note tabs are not incorrectly opened in new window during the shutdown process. --- chrome/content/zotero/tabs.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chrome/content/zotero/tabs.js b/chrome/content/zotero/tabs.js index 43d1ad3b25..5eb80b2ea9 100644 --- a/chrome/content/zotero/tabs.js +++ b/chrome/content/zotero/tabs.js @@ -781,6 +781,12 @@ var Zotero_Tabs = new function () { * Close all tabs except the first one */ this.closeAll = function () { + // Ensure a non-loadable tab is selected before bulk-close. Otherwise, + // closing the currently selected tab can auto-select an unloaded tab, + // which triggers lazy-load hooks during shutdown. + if (this._selectedID !== 'zotero-pane') { + this.select('zotero-pane'); + } this.close(this._tabs.slice(1).map(x => x.id)); };