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.
This commit is contained in:
Ramon Mi 2026-03-27 21:25:21 +08:00
parent 391e8497a6
commit 9c1af8e61c

View file

@ -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));
};