From c37a79e06620e3f76e216a305df5e84d6e03dc29 Mon Sep 17 00:00:00 2001 From: Tom Najdek Date: Tue, 13 Jan 2026 17:35:32 +0100 Subject: [PATCH] Fix library tab fields not refreshing (#5697) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, fields and the abstract in the library tab did not refresh after updates were made in the Reader’s context pane. --- chrome/content/zotero/elements/abstractBox.js | 19 ++++++++++++++++++- chrome/content/zotero/elements/itemBox.js | 19 ++++++++++++++++++- .../zotero/elements/itemPaneSection.js | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/elements/abstractBox.js b/chrome/content/zotero/elements/abstractBox.js index 010591a4c0..23779a065c 100644 --- a/chrome/content/zotero/elements/abstractBox.js +++ b/chrome/content/zotero/elements/abstractBox.js @@ -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); } diff --git a/chrome/content/zotero/elements/itemBox.js b/chrome/content/zotero/elements/itemBox.js index 56bf1003d3..28c36de908 100644 --- a/chrome/content/zotero/elements/itemBox.js +++ b/chrome/content/zotero/elements/itemBox.js @@ -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); } diff --git a/chrome/content/zotero/elements/itemPaneSection.js b/chrome/content/zotero/elements/itemPaneSection.js index 51e8d8cb90..37d8aef37e 100644 --- a/chrome/content/zotero/elements/itemPaneSection.js +++ b/chrome/content/zotero/elements/itemPaneSection.js @@ -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(); }