fix(person-mention): close popup on textarea blur
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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}
|
||||
></textarea>
|
||||
|
||||
{#if popupOpen}
|
||||
|
||||
Reference in New Issue
Block a user