Fix new annotation changing the scroll position in itemTree (#5309)

Extend scrollToRow in windowed-list.js to allow to
scroll the specified row to the top of the window
even if it is located below the current scroll window.
With this, when scroll position is restored in itemTree,
the same row remains at the top.

Fixes: #5233
This commit is contained in:
abaevbog 2025-05-29 22:31:11 -07:00 • committed by GitHub
parent cdcac8a6e1
commit 1f8e05bfd8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -202,9 +202,11 @@ module.exports = class {
/**
* Scroll the scrollbox to a specified item. No-op if already in view
* @param index
* @param {Integer} index
* @param {Boolean} forceScrollToTop If true, the row will be scrolled to the top of the scrollbox
* even if it is below the current scroll window.
*/
scrollToRow(index) {
scrollToRow(index, forceScrollToTop = false) {
const { scrollOffset } = this;
const itemCount = this._getItemCount();
const height = this.getWindowHeight();
@ -216,7 +218,7 @@ module.exports = class {
this.scrollTo(startPosition);
}
else if (endPosition > scrollOffset + height) {
this.scrollTo(endPosition - height - 1);
this.scrollTo(forceScrollToTop ? startPosition : endPosition - height - 1);
}
}

View file

@ -3752,7 +3752,7 @@ var ItemTree = class ItemTree extends LibraryTree {
if (row === false) {
return;
}
this._treebox.scrollToRow(Math.max(row - scrollPosition.offset, 0));
this._treebox.scrollToRow(Math.max(row - scrollPosition.offset, 0), true);
}
/**