From fd6ea99967a10b0668a8200181ecafa4322e43b2 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Tue, 23 May 2023 19:39:55 +0300 Subject: [PATCH] Item box: Always save current item when switching items Fixes #3125 --- chrome/content/zotero/elements/itemBox.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/elements/itemBox.js b/chrome/content/zotero/elements/itemBox.js index 832dc57b6b..27074ab1df 100644 --- a/chrome/content/zotero/elements/itemBox.js +++ b/chrome/content/zotero/elements/itemBox.js @@ -285,6 +285,18 @@ this._displayAllCreators = false; } + // If switching items, save the current item first + // Before fx102, clicking an item in the item tree would send a blur event before ItemBox.item was updated. + // Now, ItemBox.item is set first, causing us to update this._item and remove the open field before it can + // receive a blur event and trigger a save. + if (this._item && val.id != this._item.id) { + // Not awaiting the blurOpenField() call here is not great practice, but it's unavoidable - setters + // can't be async and should immediately update their backing fields. Additionally, it matches the old + // behavior, as the blur event was triggered immediately before the item setter, with the + // Zotero.Item#saveTx() call continuing in the background. + this.blurOpenField(); + } + this._item = val; this._lastTabIndex = null; this.scrollToTop(); @@ -298,7 +310,6 @@ set ref(val) { this.item = val; - this.refresh(); }