From 0b858cf4262ad374871310b7f2728b845612ebe7 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 10 Feb 2023 23:13:01 +1300 Subject: [PATCH] Unlock search suggestions properly, possibly fix safari --- static/search-suggestions.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/static/search-suggestions.js b/static/search-suggestions.js index f4586be..324bd4b 100644 --- a/static/search-suggestions.js +++ b/static/search-suggestions.js @@ -74,7 +74,7 @@ effect(() => { }) }) -document.addEventListener("pageshow", () => { +window.addEventListener("pageshow", () => { st.value = "ready" // unlock results from changing after returning to page }) @@ -88,4 +88,12 @@ render(html`<${SuggestionInput} />`, eInput) // form focus eForm.addEventListener("focusin", () => focus.value = true) -eForm.addEventListener("focusout", () => focus.value = false) +eForm.addEventListener("focusout", event => { + if (eForm.contains(event.relatedTarget)) { + // event fired when changing from one form element to the other + focus.value = true + } else { + // event fired when moving out of the form element + focus.value = false + } +})