mirror of
https://github.com/zotero/zotero.git
synced 2026-09-27 01:21:27 +00:00
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:
parent
cdcac8a6e1
commit
1f8e05bfd8
2 changed files with 6 additions and 4 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue