Fix viewItem unnecessary scroll

This commit is contained in:
windingwind 2024-01-19 10:36:28 +08:00 committed by Dan Stillman
parent 86947d7154
commit 1c343ee820
2 changed files with 23 additions and 13 deletions

View file

@ -91,6 +91,8 @@
this._section = null;
this._preview = null;
this._isRendering = false;
}
get mode() {
@ -245,7 +247,11 @@
}
async render() {
if (this._isRendering) {
return;
}
Zotero.debug('Refreshing attachment box');
this._isRendering = true;
if (this.usePreview) {
this._preview.item = this.item;
@ -386,6 +392,7 @@
else {
selectButton.hidden = true;
}
this._isRendering = false;
}
onViewClick(event) {

View file

@ -69,6 +69,8 @@ var ZoteroItemPane = new function() {
Zotero.debug('Viewing item');
_notesBox.parentItem = item;
let isSameItem = _lastItem?.id === item.id;
_lastItem = item;
@ -117,20 +119,21 @@ var ZoteroItemPane = new function() {
box.inTrash = inTrash;
}
if (pinnedPane && !_sidenav.getPane(pinnedPane)) {
pinnedPane = "";
if (!isSameItem) {
if (pinnedPane && !_sidenav.getPane(pinnedPane)) {
pinnedPane = "";
}
_scrollParent.style.paddingBottom = '';
if (pinnedPane) {
_sidenav.scrollToPane(pinnedPane, 'instant');
_sidenav.pinnedPane = pinnedPane;
}
else if (pinnedPane !== false) {
_sidenav.scrollToPane(_sidenav.getPanes()[0]?.getAttribute('data-pane'), 'instant');
}
_sidenav.render();
}
_scrollParent.style.paddingBottom = '';
if (pinnedPane) {
_sidenav.scrollToPane(pinnedPane, 'instant');
_sidenav.pinnedPane = pinnedPane;
}
else if (pinnedPane !== false) {
_sidenav.scrollToPane(_sidenav.getPanes()[0]?.getAttribute('data-pane'), 'instant');
}
_sidenav.render();
});