diff --git a/frontend/js/search.js b/frontend/js/search.js index 4b67329..c6c0f48 100644 --- a/frontend/js/search.js +++ b/frontend/js/search.js @@ -179,9 +179,10 @@ export const AutocompleteDropdown = { }, show() { - // Après un hide() récent (ex: recherche lancée), on ignore le re-show - // du fetch de suggestions en attente — sinon le dropdown recouvre l'UI. - if (this._suppressShowUntil && Date.now() < this._suppressShowUntil) return; + // Après un hide() (ex: recherche lancée), on ignore le re-show du fetch + // de suggestions en attente — sinon le dropdown recouvre l'UI. Le flag + // est réarmé par la prochaine frappe (populate) ou le focus. + if (this._suppressShow) return; if (this._dropdown) this._dropdown.hidden = false; }, @@ -189,7 +190,7 @@ export const AutocompleteDropdown = { if (this._dropdown) this._dropdown.hidden = true; state.dropdownActiveIndex = -1; state.dropdownItems = []; - this._suppressShowUntil = Date.now() + 500; + this._suppressShow = true; }, isVisible() { @@ -199,6 +200,8 @@ export const AutocompleteDropdown = { /** Populate and show the dropdown with history, title suggestions, and tag suggestions */ async populate(inputValue, cursorPos) { if (this._suppressNext) { this._suppressNext = false; return; } + // Nouvelle frappe (ou focus) : réautorise l'affichage du dropdown + this._suppressShow = false; // Cancel previous suggestion request if (state.suggestAbortController) { state.suggestAbortController.abort(); diff --git a/tests/e2e/split-view.spec.js b/tests/e2e/split-view.spec.js index 28237cd..5b73b3a 100644 --- a/tests/e2e/split-view.spec.js +++ b/tests/e2e/split-view.spec.js @@ -302,7 +302,8 @@ test.describe('Split View — Persistence', () => { const input = page.locator('#cp-input'); if (await input.isVisible()) { await input.fill('>réinitialiser'); - await page.waitForTimeout(200); + // Attendre le rendu de la liste filtrée (debounce 150ms du palette) + await page.waitForSelector('.cp-item', { timeout: 3000 }); await page.keyboard.press('Enter'); }