mirror of
https://github.com/zotero/zotero.git
synced 2026-09-07 08:26:14 +00:00
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:
parent
3c53118f2c
commit
8d59331d43
2 changed files with 24 additions and 3 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue