diff --git a/frontend/src/lib/components/PersonMentionEditor.svelte b/frontend/src/lib/components/PersonMentionEditor.svelte index 57c6102b..1f82909d 100644 --- a/frontend/src/lib/components/PersonMentionEditor.svelte +++ b/frontend/src/lib/components/PersonMentionEditor.svelte @@ -143,6 +143,14 @@ function closePopup() { clearTimeout(debounceTimer); } +function handleBlur() { + // Small delay so an option's onmousedown can fire and select before the + // popup unmounts. Without this, clicking a result on the way out would + // race with blur and lose the selection. + setTimeout(() => closePopup(), 150); + onblur?.(); +} + function handleKeydown(e: KeyboardEvent) { if (query === null) return; @@ -191,7 +199,7 @@ const popupOpen = $derived(query !== null); oninput={handleInput} onkeydown={handleKeydown} onfocus={onfocus} - onblur={onblur} + onblur={handleBlur} > {#if popupOpen}