From ba5d34876ea17155fcf88f5261f7803b099d6b23 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Wed, 14 Feb 2024 16:36:22 -0500 Subject: [PATCH] Don't fire syncfrompreference when value hasn't changed Except during initialization. Fixes an infinite loop when the Quick Copy locale is set to a custom value. --- chrome/content/zotero/preferences/preferences.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js index 9c9d56e785..45c3f239fe 100644 --- a/chrome/content/zotero/preferences/preferences.js +++ b/chrome/content/zotero/preferences/preferences.js @@ -376,12 +376,20 @@ ${str} || elem.tagName == 'checkbox'; }, - _syncFromPref(elem, preference) { + _syncFromPref(elem, preference, force = false) { let value = Zotero.Prefs.get(preference, true); if (this._useChecked(elem)) { + value = !!value; + if (!force && elem.checked === value) { + return; + } elem.checked = value; } else { + value = String(value); + if (!force && elem.value === value) { + return; + } elem.value = value; } elem.dispatchEvent(new Event('syncfrompreference')); @@ -450,7 +458,7 @@ ${str} // Set timeout before populating the value so the pane can add listeners first return new Promise(resolve => setTimeout(() => { - this._syncFromPref(elem, elem.getAttribute('preference')); + this._syncFromPref(elem, elem.getAttribute('preference'), true); resolve(); })); };