fix trashed collection treated as an item row (#5371)

If the id of the collection happens to be the same
as an id of an existing item, those objects may end
up being used interchangeably in itemTree.
The trashed collection could appear in "My Library"
instead of the item, or the not-deleted item could appear
in the trash instead of the collection.
This is addressed by using .treeViewID instead of the
.id of the objects in ItemTree.refresh and ZoteroPane.itemSelected.
This commit is contained in:
abaevbog 2025-07-14 21:30:28 -07:00 • committed by GitHub
parent 98d7d8c408
commit 387d5966c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -276,7 +276,7 @@ var ItemTree = class ItemTree extends LibraryTree {
|| item.isRegularItem();
});
}
let newSearchItemIDs = new Set(newSearchItems.map(item => item.id));
let newSearchItemIDs = new Set(newSearchItems.map(item => item.treeViewID));
// Find the items that aren't yet in the tree
let itemsToAdd = newSearchItems.filter(item => this._rowMap[item.treeViewID] === undefined);
// Find the parents of search matches
@ -318,7 +318,7 @@ var ItemTree = class ItemTree extends LibraryTree {
skipChildren = false;
}
// Skip items that don't match the search and don't have children that do
if (!newSearchItemIDs.has(row.ref.id) && !isSearchParent) {
if (!newSearchItemIDs.has(row.ref.treeViewID) && !isSearchParent) {
continue;
}
}

View file

@ -1949,7 +1949,7 @@ var ZoteroPane = new function()
// Check if selection has actually changed. The onselect event that calls this
// can be called in various situations where the selection didn't actually change,
// such as whenever selectEventsSuppressed is set to false.
var ids = selectedItems.map(item => item.id);
var ids = selectedItems.map(item => item.treeViewID);
ids.sort();
if (ids.length && Zotero.Utilities.arrayEquals(_lastSelectedItems, ids)) {
return false;