From 3aef6cddcb0fa27ae96489c54cea5c6deda1b0ee Mon Sep 17 00:00:00 2001 From: abaevbog Date: Thu, 19 Jun 2025 21:19:17 -0700 Subject: [PATCH] qf: fix breakage with unloaded tab (#5347) Properly load all item data for items opened in tabs to account for the fact that they can belong to libraries that are not yet loaded. Similar fix as in https://github.com/zotero/zotero/commit/4421de63de709c238a5418cb9747aeb2085fcd93 --- .../content/zotero/integration/quickFormat.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index f40e8992e8..c87d68146a 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -656,13 +656,22 @@ var Zotero_QuickFormat = new function () { }).map(t => t.data.itemID); if (!itemIDs.length) return []; - let items = itemIDs.map((itemID) => { - let item = Zotero.Items.get(itemID); + // Fetch top-most items and load necessary data, in case tabs belong to an unloaded library + let items = []; + for (let itemID of itemIDs) { + let item = await Zotero.Items.getAsync(itemID); if (item && item.parentItemID) { - itemID = item.parentItemID; + item = await Zotero.Items.getAsync(item.parentItemID); } - return Zotero.Cite.getItem(itemID); - }); + // Ignore tabs from libraries that are not specified + if (io.filterLibraryIDs) { + let itemInLibrary = io.filterLibraryIDs.some(id => id === item.libraryID); + if (!itemInLibrary) continue; + } + items.push(item); + } + await Zotero.Items.loadDataTypes(items); + let matchedItems = new Set(items); if (options.searchString) { Zotero.debug("QuickFormat: Searching open tabs");