Do not switch to library tab while changing target collection in connector (#5020)

Do not switch to library tab while changing target
collection in connector.

Deprecate inLibraryRoot as an independent boolean
param in ZoteroPane.selectItems to instead have
a composite options param { inLibraryRoot, noTabSwitch }

Fixes: #4262
This commit is contained in:
abaevbog 2025-04-10 04:27:20 -07:00 • committed by GitHub
parent cef26fae09
commit 060a15fe78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 7 deletions

View file

@ -183,7 +183,7 @@ var ZoteroAdvancedSearch = new function() {
return;
}
lastWin.ZoteroPane.selectItems(items.map(item => item.id), false);
lastWin.ZoteroPane.selectItems(items.map(item => item.id));
lastWin.focus();
}
}

View file

@ -62,7 +62,7 @@ async function _handleActivate(event, indices) {
let win = Services.wm.getMostRecentWindow("navigator:browser");
if (win) {
win.ZoteroPane.selectItem(itemID, false, true);
win.ZoteroPane.selectItem(itemID);
win.focus();
}
}

View file

@ -305,7 +305,7 @@ Zotero.Server.Connector.SaveSession.prototype.update = async function (targetID,
item = item.isTopLevelItem() ? item : item.parentItem;
// Don't select if in trash
if (!item.deleted) {
await zp.selectItem(item.id);
await zp.selectItem(item.id, { noTabSwitch: true });
}
}
};

View file

@ -2985,15 +2985,20 @@ var ZoteroPane = new function()
};
this.selectItem = async function (itemID, inLibraryRoot) {
this.selectItem = async function (itemID, options) {
if (!itemID) {
return false;
}
return this.selectItems([itemID], inLibraryRoot);
return this.selectItems([itemID], options);
};
this.selectItems = async function (itemIDs, inLibraryRoot) {
this.selectItems = async function (itemIDs, options = {}) {
if (typeof options == "boolean") {
Zotero.warn("ZoteroPane.selectItems() now takes an 'options' object -- update your code");
options = { inLibraryRoot: options };
}
let { inLibraryRoot, noTabSwitch } = options;
if (!itemIDs.length) {
return false;
}
@ -3019,7 +3024,10 @@ var ZoteroPane = new function()
document.getElementById(ZoteroPane.itemsView.id).focus();
}
Zotero_Tabs.select('zotero-pane', false, { focusElementID: ZoteroPane.itemsView.id });
if (!noTabSwitch) {
Zotero_Tabs.select('zotero-pane', false, { focusElementID: ZoteroPane.itemsView.id });
}
return true;
};