diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-11-23 14:16:10 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-11-23 14:16:10 +0100 |
| commit | 33faad1358ad056f0f5645705a9fe352a12dc462 (patch) | |
| tree | d60563cdaf9c89bf266adbc4e714e9adee3a4b95 /web/src/lib/ui/decks/ModifierCardZoom.svelte | |
| parent | c5e81304a31fc6dbbbbd50177481aedc8c11c32c (diff) | |
web: make card zoom overlays focusable
The dialog-role overlays need a tabindex: use tabindex="-1" (out of the
tab order, focusable programmatically) and focus the overlay when it
opens, so the existing Escape handler actually works for keyboard
users, not just mouse users.
Diffstat (limited to 'web/src/lib/ui/decks/ModifierCardZoom.svelte')
| -rw-r--r-- | web/src/lib/ui/decks/ModifierCardZoom.svelte | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/web/src/lib/ui/decks/ModifierCardZoom.svelte b/web/src/lib/ui/decks/ModifierCardZoom.svelte index 68cb150..98f32ea 100644 --- a/web/src/lib/ui/decks/ModifierCardZoom.svelte +++ b/web/src/lib/ui/decks/ModifierCardZoom.svelte @@ -28,13 +28,21 @@ return Math.min(DEFAULT_ZOOM, window.innerWidth / (CARD_WIDTH + 80)); } const scale = $state(scaleFor()); + + let zoomEl: HTMLDivElement | undefined = $state(); + $effect(() => { + // Focus the overlay when it opens so Escape (keyboard) can close it. + if (open) zoomEl?.focus(); + }); </script> {#if open} <div + bind:this={zoomEl} class="zoom" role="dialog" aria-modal="true" + tabindex="-1" onclick={() => (open = false)} onkeydown={(e) => e.key === 'Escape' && (open = false)} > |
