From 2e3deb0a215e7d27febde90084773836be325e32 Mon Sep 17 00:00:00 2001 From: abaevbog Date: Wed, 8 Oct 2025 12:37:17 -0700 Subject: [PATCH] tagsbox: fix deleted tags reappearing (#5533) https://forums.zotero.org/discussion/110655/z7-beta-tags-reappear-after-quickly-deleting-them If a library has many tags and one quickly clicks on "-" button to deleted multiple tags from an item, the database updates may not keep up with UI. To address this, save item only once after a debounce. Fixes: #5410 --- chrome/content/zotero/elements/tagsBox.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/elements/tagsBox.js b/chrome/content/zotero/elements/tagsBox.js index 5b59d30df0..e2c3640a14 100644 --- a/chrome/content/zotero/elements/tagsBox.js +++ b/chrome/content/zotero/elements/tagsBox.js @@ -241,7 +241,11 @@ this.remove(tagName); try { item.removeTag(tagName); - await item.saveTx(); + // Save item after a debounce to avoid triggering multiple + // save operations. If there are many tags in the library, + // db transaction may not keep up with UI changes, and cause + // some deleted rows to reappear. + this._saveItemDebounced(item); } catch (e) { this._forceRenderAll(); @@ -638,6 +642,10 @@ } } + _saveItemDebounced = Zotero.Utilities.debounce(async (item) => { + await item.saveTx(); + }); + _id(id) { return this.querySelector(`[id=${id}]`); }