Fix library tab fields not refreshing (#5697)

Previously, fields and the abstract in the library tab did not refresh after updates were made in the Reader’s context pane.
This commit is contained in:
Tom Najdek 2026-01-13 17:35:32 +01:00 • committed by GitHub
parent e899012e5e
commit c37a79e066
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 3 deletions

View file

@ -67,7 +67,7 @@
}
init() {
this._notifierID = Zotero.Notifier.registerObserver(this, ['item'], 'abstractBox');
this._notifierID = Zotero.Notifier.registerObserver(this, ['item', 'tab'], 'abstractBox');
this.initCollapsibleSection();
@ -86,6 +86,9 @@
if (action == 'modify' && this.item && ids.includes(this.item.id)) {
this._forceRenderAll();
}
if (action === 'select' && type === 'tab' && ids.length > 0) {
this._handleTabSelect(ids[0]);
}
}
async save() {
@ -203,6 +206,20 @@
_handleFieldBlur = () => {
this.save();
};
_handleTabSelect = (tabID) => {
if (!this.tabID || typeof Zotero_Tabs === 'undefined') {
return;
}
if (tabID !== this.tabID) {
return;
}
if (this._syncRenderPending) {
this._syncRenderPending = false;
this.render();
}
};
}
customElements.define("abstract-box", AbstractBox);
}

View file

@ -153,7 +153,7 @@
// Ensure no button is forced to stay visible once the menu is closed
this.addEventListener('popuphidden', this._handlePopupHidden);
this._notifierID = Zotero.Notifier.registerObserver(this, ['item', 'infobox'], 'itemBox');
this._notifierID = Zotero.Notifier.registerObserver(this, ['item', 'infobox', 'tab'], 'itemBox');
this._prefsObserverID = Zotero.Prefs.registerObserver('fontSize', () => {
this._forceRenderAll();
});
@ -403,6 +403,9 @@
if (event == 'modify' && this.item?.id && ids.includes(this.item.id)) {
this._forceRenderAll();
}
if (event === 'select' && type === 'tab' && ids.length > 0) {
this._handleTabSelect(ids[0]);
}
}
render() {
@ -2967,6 +2970,20 @@
this.removeUnsavedCreatorRow(true);
}
};
_handleTabSelect = (tabID) => {
if (!this.tabID || typeof Zotero_Tabs === 'undefined') {
return;
}
if (tabID !== this.tabID) {
return;
}
if (this._syncRenderPending) {
this._syncRenderPending = false;
this.render();
}
};
}
customElements.define("info-box", InfoBox);
}

View file

@ -167,12 +167,12 @@ class ItemPaneSectionElementBase extends XULElementBase {
}
async _forceRenderAll() {
this._resetRenderedFlags();
if (this.hidden || this.skipRender) {
this._syncRenderPending = true;
this._asyncRenderPending = true;
return;
}
this._resetRenderedFlags();
if (this.render) this.render();
if (this.asyncRender) await this.asyncRender();
}