Don't clear quick search after removal from collection (#4618)
Do not try to re-select a previously selected item if it was filtered out from itemTree, e.g. after it was removed from currently selected collection. Otherwise, quick search gets cleared in an attempt to re-select the item. Fixes: #4616
This commit is contained in:
parent
c937b36e25
commit
7fa00d1cfd
2 changed files with 21 additions and 2 deletions
|
@ -826,9 +826,11 @@ var ItemTree = class ItemTree extends LibraryTree {
|
||||||
reselect = true;
|
reselect = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If single item is selected and was modified
|
// If a single item is selected, was modified, and is not filtered out,
|
||||||
|
// make sure it's selected
|
||||||
else if (action == 'modify' && ids.length == 1 &&
|
else if (action == 'modify' && ids.length == 1 &&
|
||||||
savedSelection.length == 1 && savedSelection[0].id == ids[0]) {
|
savedSelection.length == 1 && savedSelection[0].id == ids[0]
|
||||||
|
&& this.getRowIndexByID(ids[0]) !== false) {
|
||||||
if (activeWindow) {
|
if (activeWindow) {
|
||||||
await this.selectItem(ids[0]);
|
await this.selectItem(ids[0]);
|
||||||
reselect = true;
|
reselect = true;
|
||||||
|
|
|
@ -160,6 +160,23 @@ describe("Zotero.ItemTree", function() {
|
||||||
assert.equal(itemsView.getRow(1).level, 1);
|
assert.equal(itemsView.getRow(1).level, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not clear quick search after deleting item from collection", async function () {
|
||||||
|
let col = await createDataObject('collection');
|
||||||
|
let item = await createDataObject('item', { title: "test", collections: [col.id] });
|
||||||
|
await zp.collectionsView.selectCollection(col.id);
|
||||||
|
|
||||||
|
quicksearch.value = "test";
|
||||||
|
quicksearch.doCommand();
|
||||||
|
await itemsView._refreshPromise;
|
||||||
|
|
||||||
|
await zp.itemsView.selectItems([item.id]);
|
||||||
|
item.removeFromCollection(col.id);
|
||||||
|
await item.saveTx();
|
||||||
|
|
||||||
|
await itemsView._refreshPromise;
|
||||||
|
assert.equal(quicksearch.value, "test");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#selectItem()", function () {
|
describe("#selectItem()", function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue