From 1e688727880d06fc853d5037100d96ead92abdce Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 20 Jul 2026 15:49:58 -0400 Subject: [PATCH] Fall back from best-match mode when semantic search is disabled Rows kept identifying the active mode as bestMatch after the model was disabled in the preferences, leaving the active filter returning nothing. Observe the model pref, switch to Fields & Tags, and rerun any active search. --- .../zotero/elements/quickSearchTextbox.js | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/elements/quickSearchTextbox.js b/chrome/content/zotero/elements/quickSearchTextbox.js index 43f9d16fda..5651aa357d 100644 --- a/chrome/content/zotero/elements/quickSearchTextbox.js +++ b/chrome/content/zotero/elements/quickSearchTextbox.js @@ -67,6 +67,13 @@ this.searchTextbox.value = val; } + disconnectedCallback() { + if (this._modelPrefObserverID) { + Zotero.Prefs.unregisterObserver(this._modelPrefObserverID); + this._modelPrefObserverID = null; + } + } + connectedCallback() { let content = document.importNode(this.content, true); this.append(content); @@ -131,8 +138,22 @@ this._advancedButton = advancedButton; } + // Disabling semantic search in the preferences invalidates an active + // best-match mode: fall back to Fields & Tags and rerun any active + // search under the new mode + this._modelPrefObserverID = Zotero.Prefs.registerObserver('embeddings.model', () => { + if (Zotero.Prefs.get('search.quicksearch-mode') === 'bestMatch' + && !Zotero.Embeddings.isEnabled()) { + Zotero.Prefs.set('search.quicksearch-mode', 'fields'); + this.updateMode(); + if (this.value) { + this.dispatchEvent(new Event('command')); + } + } + }); + this.deck = this.firstElementChild; - + this.querySelector('.advanced-collapse-button').addEventListener('command', (event) => { event.stopPropagation(); ZoteroPane.toggleAdvancedSearchState('collapsed');