HTML Tree: Make search context rows selectable. Closes #2164

Adds special handling such that context rows are not selected only
when performing a select-all.
This commit is contained in:
Adomas Venčkauskas 2021-08-27 13:36:03 +03:00
parent 0a7aa10463
commit b05e22fa77
2 changed files with 12 additions and 7 deletions

View file

@ -138,21 +138,21 @@ class TreeSelection {
return true;
}
_rangedSelect(from, to, augment) {
_rangedSelect(from, to, augment, isSelectAll) {
from = Math.max(0, from);
to = Math.max(0, to);
if (!augment) {
this.selected = new Set();
}
for (let i = from; i <= to; i++) {
if (this._tree.props.isSelectable(i)) {
if (this._tree.props.isSelectable(i, isSelectAll)) {
this.selected.add(i);
}
}
}
rangedSelect(from, to, augment) {
this._rangedSelect(from, to, augment);
rangedSelect(from, to, augment, isSelectAll) {
this._rangedSelect(from, to, augment, isSelectAll);
if (this.selectEventsSuppressed) return;
@ -554,7 +554,7 @@ 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) this.selection.rangedSelect(0, this.props.getRowCount()-1, false, true);
break;
case " ":

View file

@ -1841,8 +1841,13 @@ var ItemTree = class ItemTree extends LibraryTree {
return fields;
}
isSelectable = (index) => {
if (!this._searchMode || this.collectionTreeRow.isPublications()) return true;
/**
* @param index {Integer}
* @param selectAll {Boolean} Whether the selection is part of a select-all event
* @returns {Boolean}
*/
isSelectable = (index, selectAll=false) => {
if (!selectAll || !this._searchMode || this.collectionTreeRow.isPublications()) return true;
let row = this.getRow(index);
return row && this._searchItemIDs.has(row.id);
}