From a993ac74f158f865de0c0d1f4da882feb1fc8f6e Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Wed, 13 Aug 2025 21:59:26 -0600 Subject: [PATCH] Ensure read-only fields don't save on blur (#5468) Fixes tabbing out of Scaffold's abstract box causing the test item to be added to the user's library. And use same format as itemPaneHeader.js in abstractBox.js. --- chrome/content/zotero/elements/abstractBox.js | 12 +++++++++--- chrome/content/zotero/elements/itemPaneHeader.js | 6 ++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/elements/abstractBox.js b/chrome/content/zotero/elements/abstractBox.js index f5bd62d954..010591a4c0 100644 --- a/chrome/content/zotero/elements/abstractBox.js +++ b/chrome/content/zotero/elements/abstractBox.js @@ -89,9 +89,15 @@ } async save() { - if (this.item) { - this.item.setField('abstractNote', this._abstractField.value); - await this.item.saveTx(); + if (!this.editable) { + return; + } + if (this._item) { + if (!this._item.itemID) { + throw new Error('Item has not been added to library'); + } + this._item.setField('abstractNote', this._abstractField.value); + await this._item.saveTx(); } this._forceRenderAll(); } diff --git a/chrome/content/zotero/elements/itemPaneHeader.js b/chrome/content/zotero/elements/itemPaneHeader.js index edd8338187..52289722a4 100644 --- a/chrome/content/zotero/elements/itemPaneHeader.js +++ b/chrome/content/zotero/elements/itemPaneHeader.js @@ -180,7 +180,13 @@ } async save() { + if (!this.editable) { + return; + } if (this._item) { + if (!this._item.itemID) { + throw new Error('Item has not been added to library'); + } this._item.setField(this._titleFieldID, this.titleField.value); await this._item.saveTx(); }