From 8d59331d4359cdbedfe6f5efbc0945fbba6773c9 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 4 May 2026 13:49:18 -0400 Subject: [PATCH] Fix quick search not expanding annotation rows after item tree refactor https://forums.zotero.org/discussion/131294/quick-search-does-not-expand-annotations-10-0-beta4 --- .../content/zotero/collectionViewItemTree.jsx | 5 ++--- test/tests/collectionViewItemTreeTest.js | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/collectionViewItemTree.jsx b/chrome/content/zotero/collectionViewItemTree.jsx index 4d0bd029a9..7f2438e878 100644 --- a/chrome/content/zotero/collectionViewItemTree.jsx +++ b/chrome/content/zotero/collectionViewItemTree.jsx @@ -336,7 +336,6 @@ class CollectionViewItemTreeRowProvider extends ItemTreeRowProvider { return; } - let rowsToOpen = []; for (let i = 0; i < this.rowCount; i++) { if (!this.isContainer(i) || this.isContainerOpen(i)) { continue; @@ -347,10 +346,10 @@ class CollectionViewItemTreeRowProvider extends ItemTreeRowProvider { // OR if it has a child that is a parent of a match let shouldBeOpened = searchParentIDs.has(item.id) || attachments.some(id => searchParentIDs.has(id)); if (shouldBeOpened) { - rowsToOpen.push(i); + this._toggleOpenState(i, true); } } - this._expandRows(rowsToOpen); + this.refreshRowMap(); } expandMatchParents() { diff --git a/test/tests/collectionViewItemTreeTest.js b/test/tests/collectionViewItemTreeTest.js index 6d3b2c1a68..190b87c194 100644 --- a/test/tests/collectionViewItemTreeTest.js +++ b/test/tests/collectionViewItemTreeTest.js @@ -182,6 +182,28 @@ describe("CollectionViewItemTree", function () { assert.equal(quicksearch.value, "test"); }); + it("should expand parent item and attachment for an annotation match", async function () { + Zotero.Prefs.set("hideContextAnnotationRows", false); + + let item = await createDataObject('item', { title: "Collapsed Parent" }); + let attachment = await importFileAttachment('test.pdf', { title: 'PDF', parentItemID: item.id }); + let annotation = await createAnnotation('highlight', attachment, { comment: "uniqueAnnotationTerm" }); + + itemsView.collapseAllRows(); + + await zp.itemsView.setFilter('search', "uniqueAnnotationTerm"); + + let itemRow = itemsView.getRowIndexByID(item.id); + assert.isNumber(itemRow); + assert.isTrue(itemsView.isContainerOpen(itemRow)); + + let attachmentRow = itemsView.getRowIndexByID(attachment.id); + assert.isNumber(attachmentRow); + assert.isTrue(itemsView.isContainerOpen(attachmentRow)); + + assert.isNumber(itemsView.getRowIndexByID(annotation.id)); + }); + it("should keep attachment rows collapsed unless search matches annotation text when hideContextAnnotationRows=true", async function () { Zotero.Prefs.set("hideContextAnnotationRows", true);