From e2905b22ad3013864ac1e57447f7e7a4deb4e68a Mon Sep 17 00:00:00 2001 From: abaevbog Date: Wed, 6 Nov 2024 20:08:16 -0800 Subject: [PATCH] arrowUp/down in duplicates view will select the set (#4800) When duplicates collectionTreeRow is selected, arrowUp/down within itemTree will select the entire previous/next set of duplicate items. Per discussion based on https://forums.zotero.org/discussion/119217/bug-zotero-7-beta-duplicates-collection-navigation-via-arrow-keys --- chrome/content/zotero/itemTree.jsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/chrome/content/zotero/itemTree.jsx b/chrome/content/zotero/itemTree.jsx index 68e687a693..838380de72 100644 --- a/chrome/content/zotero/itemTree.jsx +++ b/chrome/content/zotero/itemTree.jsx @@ -978,6 +978,24 @@ var ItemTree = class ItemTree extends LibraryTree { this.collapseAllRows(); return false; } + // On arrowUp/down without modifiers in duplicates view, select the entire set + else if (this.collectionTreeRow.isDuplicates() && ["ArrowUp", "ArrowDown"].includes(event.key) + && !event.shiftKey && !event.ctrlKey && !event.metaKey && !event.altKey) { + // Find the first row outside of the current consecutive set of rows + let findNextRow = index => (event.key == "ArrowUp" ? index - 1 : index + 1); + let nextRowIndex = findNextRow(this.selection.focused); + while (this.selection.selected.has(nextRowIndex)) { + nextRowIndex = findNextRow(nextRowIndex); + } + if (nextRowIndex < 0 || nextRowIndex > this._rows.length - 1) return false; + // Set that row as focused and select its item as the next set of duplicates + let nextItem = this._rows[nextRowIndex].ref; + var setItemIDs = this.collectionTreeRow.ref.getSetItemsByItemID(nextItem.id); + this.selection.focused = nextRowIndex; + + this.selectItems(setItemIDs); + return false; + } return true; }