diff --git a/chrome/content/zotero/components/windowed-list.js b/chrome/content/zotero/components/windowed-list.js index 9661735780..4a755a123a 100644 --- a/chrome/content/zotero/components/windowed-list.js +++ b/chrome/content/zotero/components/windowed-list.js @@ -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); } } diff --git a/chrome/content/zotero/itemTree.jsx b/chrome/content/zotero/itemTree.jsx index 0607cb609a..4ae8181c61 100644 --- a/chrome/content/zotero/itemTree.jsx +++ b/chrome/content/zotero/itemTree.jsx @@ -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); } /**