refactor(TranscriptionReadView): rename handleMentionLeave, closeTimer to \$state, add 150ms comment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-29 21:27:43 +02:00
parent 9908f7afdc
commit 3c7c7a9aa4

View File

@@ -97,9 +97,11 @@ function currentViewport() {
};
}
let closeTimer: ReturnType<typeof setTimeout> | null = null;
let closeTimer = $state<ReturnType<typeof setTimeout> | null>(null);
function scheduleCardClose() {
// 150ms: long enough for pointer movement from mention to card, short enough
// to feel responsive. Matches the Radix/shadcn hover card delay.
closeTimer = setTimeout(() => {
activeCard = null;
closeTimer = null;
@@ -152,7 +154,7 @@ async function handleMentionEnter(event: Event) {
}
}
function handleMentionLeave(event: Event) {
function scheduleMentionLeave(event: Event) {
const link = event.target as HTMLAnchorElement;
link.removeAttribute('aria-describedby');
scheduleCardClose();
@@ -195,7 +197,7 @@ function attachMentionHandlers(node: HTMLElement) {
}
function onLeave(e: Event) {
const t = e.target as HTMLElement;
if (t.matches?.(PERSON_MENTION_SELECTOR)) handleMentionLeave(e);
if (t.matches?.(PERSON_MENTION_SELECTOR)) scheduleMentionLeave(e);
}
function onClick(e: MouseEvent) {
const t = e.target as HTMLElement;