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
This commit is contained in:
Dan Stillman 2026-05-04 13:49:18 -04:00
parent 3c53118f2c
commit 8d59331d43
2 changed files with 24 additions and 3 deletions

View file

@ -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() {

View file

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