From f0bb1c3163a7ac98fd4e7e0ea4564004911e85b3 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 29 Apr 2026 01:11:33 +0200 Subject: [PATCH] fix(person-mention): close popup on textarea blur MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Leonie #5507 concern 1: tabbing away from the editor left the popup hanging over the next field. Add a 150ms-deferred close on blur — the delay lets onmousedown on a result fire before the popup unmounts (the race that the existing onmousedown+e.preventDefault() pattern depends on). Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/lib/components/PersonMentionEditor.svelte | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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}