From aa7e502bad45ee704a43b18592cb0c3b4a987631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Wed, 27 Oct 2021 13:16:31 +0300 Subject: [PATCH] Restore ability to select individual items in duplicates view. Closes #2225. Only mouse clicks without modifiers will select the group of duplicate items. This is the same behavior as with the XUL tree. --- .../content/zotero/components/virtualized-table.jsx | 4 +++- chrome/content/zotero/itemTree.jsx | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/components/virtualized-table.jsx b/chrome/content/zotero/components/virtualized-table.jsx index 0b9f75816c..b2eed717f6 100644 --- a/chrome/content/zotero/components/virtualized-table.jsx +++ b/chrome/content/zotero/components/virtualized-table.jsx @@ -687,7 +687,9 @@ class VirtualizedTable extends React.Component { this._isMouseDrag = false; return; } - this._onSelection(index, shiftSelect, toggleSelection); + if (shiftSelect || toggleSelection) { + this._onSelection(index, shiftSelect, toggleSelection); + } } _activateNode = (event, indices) => { diff --git a/chrome/content/zotero/itemTree.jsx b/chrome/content/zotero/itemTree.jsx index b60244e5ba..fae0ec9904 100644 --- a/chrome/content/zotero/itemTree.jsx +++ b/chrome/content/zotero/itemTree.jsx @@ -2664,14 +2664,22 @@ var ItemTree = class ItemTree extends LibraryTree { this.onDrop(e, index); }, { passive: true }); } + div.addEventListener('mousedown', e => this._handleRowMouseDown(e, index), { passive : true }); } return div; }; + + _handleRowMouseDown = (event, index) => { + const modifierIsPressed = ['ctrlKey', 'metaKey', 'shiftKey', 'altKey'].some(key => event[key]); + if (this.collectionTreeRow.isDuplicates() && !modifierIsPressed) { + this.duplicateMouseSelection = true; + } + } _handleSelectionChange = (selection, shouldDebounce) => { // Update aria-activedescendant on the tree - if (this.collectionTreeRow.isDuplicates() && selection.count == 1) { + if (this.collectionTreeRow.isDuplicates() && selection.count == 1 && this.duplicateMouseSelection) { var itemID = this.getRow(selection.focused).ref.id; var setItemIDs = this.collectionTreeRow.ref.getSetItemsByItemID(itemID); @@ -2682,6 +2690,7 @@ var ItemTree = class ItemTree extends LibraryTree { this.tree.invalidateRow(this._rowMap[id]); } } + this.duplicateMouseSelection = false; if (shouldDebounce) { this._onSelectionChangeDebounced(); }