Merge pull request #16321 from itk-dev/feature/more-accessible-menu

Feat: enhance accessibility of menu
This commit is contained in:
Tim Jaeryang Baek
2025-08-06 15:13:13 +04:00
committed by GitHub
8 changed files with 25 additions and 7 deletions

View File

@@ -255,6 +255,7 @@
}} }}
> >
<button <button
aria-label={`${$i18n.t('More Options')}`}
class="flex" class="flex"
on:click={(e) => { on:click={(e) => {
e.preventDefault(); e.preventDefault();

View File

@@ -32,7 +32,12 @@
typeahead={false} typeahead={false}
> >
<DropdownMenu.Trigger> <DropdownMenu.Trigger>
<Tooltip content={$i18n.t('More')} className=" group-hover/item:opacity-100 opacity-0"> <Tooltip
content={$i18n.t('More')}
className={($settings?.highContrastMode ?? false)
? ''
: 'group-hover/item:opacity-100 opacity-0'}
>
<slot /> <slot />
</Tooltip> </Tooltip>
</DropdownMenu.Trigger> </DropdownMenu.Trigger>
@@ -45,8 +50,9 @@
align="end" align="end"
transition={flyAndScale} transition={flyAndScale}
> >
<button <DropdownMenu.Item
type="button" type="button"
aria-pressed={($settings?.pinnedModels ?? []).includes(model?.id)}
class="flex rounded-md py-1.5 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition items-center gap-2" class="flex rounded-md py-1.5 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition items-center gap-2"
on:click={(e) => { on:click={(e) => {
e.stopPropagation(); e.stopPropagation();
@@ -69,9 +75,9 @@
{$i18n.t('Keep in Sidebar')} {$i18n.t('Keep in Sidebar')}
{/if} {/if}
</div> </div>
</button> </DropdownMenu.Item>
<button <DropdownMenu.Item
type="button" type="button"
class="flex rounded-md py-1.5 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition items-center gap-2" class="flex rounded-md py-1.5 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition items-center gap-2"
on:click={(e) => { on:click={(e) => {
@@ -85,6 +91,6 @@
<Link /> <Link />
<div class="flex items-center">{$i18n.t('Copy Link')}</div> <div class="flex items-center">{$i18n.t('Copy Link')}</div>
</button> </DropdownMenu.Item>
</DropdownMenu.Content> </DropdownMenu.Content>
</DropdownMenu.Root> </DropdownMenu.Root>

View File

@@ -394,6 +394,7 @@
class="w-full text-sm bg-transparent outline-hidden" class="w-full text-sm bg-transparent outline-hidden"
placeholder={searchPlaceholder} placeholder={searchPlaceholder}
autocomplete="off" autocomplete="off"
aria-label={$i18n.t('Search In Models')}
on:keydown={(e) => { on:keydown={(e) => {
if (e.code === 'Enter' && filteredItems.length > 0) { if (e.code === 'Enter' && filteredItems.length > 0) {
value = filteredItems[selectedModelIdx].value; value = filteredItems[selectedModelIdx].value;
@@ -436,6 +437,7 @@
selectedConnectionType === '' selectedConnectionType === ''
? '' ? ''
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize" : 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
aria-pressed={selectedTag === '' && selectedConnectionType === ''}
on:click={() => { on:click={() => {
selectedConnectionType = ''; selectedConnectionType = '';
selectedTag = ''; selectedTag = '';
@@ -450,6 +452,7 @@
class="min-w-fit outline-none p-1.5 {selectedConnectionType === 'local' class="min-w-fit outline-none p-1.5 {selectedConnectionType === 'local'
? '' ? ''
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize" : 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
aria-pressed={selectedConnectionType === 'local'}
on:click={() => { on:click={() => {
selectedTag = ''; selectedTag = '';
selectedConnectionType = 'local'; selectedConnectionType = 'local';
@@ -464,6 +467,7 @@
class="min-w-fit outline-none p-1.5 {selectedConnectionType === 'external' class="min-w-fit outline-none p-1.5 {selectedConnectionType === 'external'
? '' ? ''
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize" : 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
aria-pressed={selectedConnectionType === 'external'}
on:click={() => { on:click={() => {
selectedTag = ''; selectedTag = '';
selectedConnectionType = 'external'; selectedConnectionType = 'external';
@@ -478,6 +482,7 @@
class="min-w-fit outline-none p-1.5 {selectedConnectionType === 'direct' class="min-w-fit outline-none p-1.5 {selectedConnectionType === 'direct'
? '' ? ''
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize" : 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
aria-pressed={selectedConnectionType === 'direct'}
on:click={() => { on:click={() => {
selectedTag = ''; selectedTag = '';
selectedConnectionType = 'direct'; selectedConnectionType = 'direct';
@@ -492,6 +497,7 @@
class="min-w-fit outline-none p-1.5 {selectedTag === tag class="min-w-fit outline-none p-1.5 {selectedTag === tag
? '' ? ''
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize" : 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
aria-pressed={selectedTag === tag}
on:click={() => { on:click={() => {
selectedConnectionType = ''; selectedConnectionType = '';
selectedTag = tag; selectedTag = tag;
@@ -613,7 +619,7 @@
{#if showTemporaryChatControl} {#if showTemporaryChatControl}
<div class="flex items-center mx-2 mt-1 mb-2"> <div class="flex items-center mx-2 mt-1 mb-2">
<button <DropdownMenu.Item
class="flex justify-between w-full font-medium line-clamp-1 select-none items-center rounded-button py-2 px-3 text-sm text-gray-700 dark:text-gray-100 outline-hidden transition-all duration-75 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer data-highlighted:bg-muted" class="flex justify-between w-full font-medium line-clamp-1 select-none items-center rounded-button py-2 px-3 text-sm text-gray-700 dark:text-gray-100 outline-hidden transition-all duration-75 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer data-highlighted:bg-muted"
on:click={async () => { on:click={async () => {
temporaryChatEnabled.set(!$temporaryChatEnabled); temporaryChatEnabled.set(!$temporaryChatEnabled);
@@ -642,7 +648,7 @@
<div> <div>
<Switch state={$temporaryChatEnabled} /> <Switch state={$temporaryChatEnabled} />
</div> </div>
</button> </DropdownMenu.Item>
</div> </div>
{:else} {:else}
<div class="mb-3"></div> <div class="mb-3"></div>

View File

@@ -9,6 +9,7 @@
viewBox="0 0 24 24" viewBox="0 0 24 24"
stroke-width={strokeWidth} stroke-width={strokeWidth}
stroke="currentColor" stroke="currentColor"
aria-hidden="true"
class={className} class={className}
> >
<path <path

View File

@@ -10,6 +10,7 @@
stroke-width={strokeWidth} stroke-width={strokeWidth}
stroke="currentColor" stroke="currentColor"
class={className} class={className}
aria-hidden="true"
> >
<path <path
stroke-linecap="round" stroke-linecap="round"

View File

@@ -10,6 +10,7 @@
stroke-width={strokeWidth} stroke-width={strokeWidth}
stroke="currentColor" stroke="currentColor"
class={className} class={className}
aria-hidden="true"
> >
<path <path
stroke-linecap="round" stroke-linecap="round"

View File

@@ -7,6 +7,7 @@
fill-rule="evenodd" fill-rule="evenodd"
d="M8.914 6.025a.75.75 0 0 1 1.06 0 3.5 3.5 0 0 1 0 4.95l-2 2a3.5 3.5 0 0 1-5.396-4.402.75.75 0 0 1 1.251.827 2 2 0 0 0 3.085 2.514l2-2a2 2 0 0 0 0-2.828.75.75 0 0 1 0-1.06Z" d="M8.914 6.025a.75.75 0 0 1 1.06 0 3.5 3.5 0 0 1 0 4.95l-2 2a3.5 3.5 0 0 1-5.396-4.402.75.75 0 0 1 1.251.827 2 2 0 0 0 3.085 2.514l2-2a2 2 0 0 0 0-2.828.75.75 0 0 1 0-1.06Z"
clip-rule="evenodd" clip-rule="evenodd"
aria-hidden="true"
/> />
<path <path
fill-rule="evenodd" fill-rule="evenodd"

View File

@@ -9,6 +9,7 @@
viewBox="0 0 24 24" viewBox="0 0 24 24"
stroke-width={strokeWidth} stroke-width={strokeWidth}
stroke="currentColor" stroke="currentColor"
aria-hidden="true"
class={className} class={className}
> >
<path <path