HTML tree: ensureRowsAreVisible() shouldn't scroll if unnecessary

Fixes #2166
This commit is contained in:
Dan Stillman 2021-09-01 01:45:54 -04:00
parent c5d89f6d07
commit dadf630728
2 changed files with 13 additions and 0 deletions

View file

@ -1180,6 +1180,13 @@ class VirtualizedTable extends React.Component {
focus() {
setTimeout(() => this._topDiv.focus());
}
rowIsVisible(row) {
if (!this._jsWindow) return false;
return row >= this._jsWindow.getFirstVisibleRow()
&& row <= this._jsWindow.getLastVisibleRow();
}
}
/**

View file

@ -1468,6 +1468,12 @@ var ItemTree = class ItemTree extends LibraryTree {
indices = Array.from(indices).filter(index => index < this._rows.length);
indices.sort((a, b) => a - b);
// If all rows are already visible, don't do anything
if (indices.every(x => this.tree.rowIsVisible(x))) {
//Zotero.debug("All indices are already visible");
return;
}
var indicesWithParents = [];
for (let row of indices) {
let parent = this.getParentIndex(row);