From 1db2eb4aea77f8c448faa02e719a7e8f7ab0e766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Wed, 14 Apr 2021 15:05:22 +0300 Subject: [PATCH] Ensure disabled item tree rows are not selectible with Select All --- .../zotero/components/virtualized-table.jsx | 17 ++++++++++++++++- chrome/content/zotero/itemTree.jsx | 6 +++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/components/virtualized-table.jsx b/chrome/content/zotero/components/virtualized-table.jsx index 84c9334f03..8c781c787b 100644 --- a/chrome/content/zotero/components/virtualized-table.jsx +++ b/chrome/content/zotero/components/virtualized-table.jsx @@ -542,7 +542,22 @@ class VirtualizedTable extends React.Component { case "a": // i.e. if CTRL/CMD pressed down - if (movePivot) this.selection.rangedSelect(0, this.props.getRowCount()-1); + if (movePivot) { + // Do not select unselectable (disabled) rows + for (let i = 0; i < this.props.getRowCount(); i++) { + if (this.props.isSelectable(i)) { + this.selection.selected.add(i); + } else { + this.selection.selected.delete(i); + } + } + if (this.selection.selectEventsSuppressed) break; + this.invalidate(); + if (!this.selection.selectEventsSuppressed) { + this.props.onSelectionChange(this, shouldDebounce); + } + this.selection.rangedSelect(0, this.props.getRowCount()-1); + } break; case " ": diff --git a/chrome/content/zotero/itemTree.jsx b/chrome/content/zotero/itemTree.jsx index d0df4db30a..9ddd945121 100644 --- a/chrome/content/zotero/itemTree.jsx +++ b/chrome/content/zotero/itemTree.jsx @@ -1128,7 +1128,7 @@ var ItemTree = class ItemTree extends LibraryTree { multiSelect: true, onSelectionChange: this._handleSelectionChange, - isSelectable: () => true, + isSelectable: this.isSelectable, getParentIndex: this.getParentIndex, isContainer: this.isContainer, isContainerEmpty: this.isContainerEmpty, @@ -1904,6 +1904,10 @@ var ItemTree = class ItemTree extends LibraryTree { } } + isSelectable = (index) => { + return !this._searchMode || this._searchItemIDs.has(this.getRow(index).id); + } + isContainer = (index) => { return this.getRow(index).ref.isRegularItem(); }