fix(a11y): opening the Terminal menu focuses its first terminal, not the Add Terminal button, and the arrow keys move through the terminals (#33153)

This commit is contained in:
G30 2026-10-25 01:14:04 -04:00 • committed by GitHub
parent d378fe81cb
commit 5cc0ed71d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -208,6 +208,8 @@
{#each directTerminals as terminal}
<button
type="button"
role="menuitemradio"
aria-checked={$selectedTerminalId === terminal.url}
class="flex w-full justify-between gap-2 items-center h-[1.6875rem] px-2 text-[0.8125rem] font-normal cursor-pointer rounded-xl {$selectedTerminalId ===
terminal.url
? 'bg-gray-50/40 dark:bg-gray-800/40'
@ -277,6 +279,8 @@
{#each systemTerminals as terminal}
<button
type="button"
role="menuitemradio"
aria-checked={$selectedTerminalId === terminal.id}
class="flex w-full justify-between gap-2 items-center h-[1.6875rem] px-2 text-[0.8125rem] font-normal cursor-pointer rounded-xl {$selectedTerminalId ===
terminal.id
? 'bg-gray-50/40 dark:bg-gray-800/40'

View file

@ -258,8 +258,15 @@
if (shouldFocusContent) {
shouldFocusContent = false;
const firstControl = contentEl?.querySelector<HTMLElement>(
'button:not([disabled]), a[href], input'
);
(
contentEl?.querySelector<HTMLElement>('button:not([disabled]), a[href], input') ?? contentEl
(firstControl?.matches('input')
? firstControl
: contentEl?.querySelector<HTMLElement>('[role^="menuitem"]:not([disabled])')) ??
firstControl ??
contentEl
)?.focus();
}
}