fix(a11y): focus moves to the other sidebar button when you open or close the sidebar (#32893)

This commit is contained in:
G30 2026-10-22 14:49:09 -04:00 • committed by GitHub
parent d6e29020c0
commit 61b49c2dd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -108,6 +108,8 @@
let scrollTop = 0;
let navElement: HTMLDivElement;
let openSidebarButton: HTMLButtonElement;
let closeSidebarButton: HTMLButtonElement;
let shiftKey = false;
let selectedChatId = null;
@ -1075,6 +1077,8 @@
class="flex flex-col flex-1 {isWindows ? 'cursor-pointer' : 'cursor-[e-resize]'}"
on:click={async () => {
showSidebar.set(!$showSidebar);
await tick();
closeSidebarButton?.focus();
}}
>
<div class="pb-1">
@ -1083,6 +1087,7 @@
placement="right"
>
<button
bind:this={openSidebarButton}
class="flex size-8.5 items-center justify-center transition group {isWindows
? 'cursor-pointer'
: 'cursor-[e-resize]'}"
@ -1305,11 +1310,14 @@
placement="bottom"
>
<button
bind:this={closeSidebarButton}
class="flex size-[1.875rem] justify-center items-center rounded-lg hover:bg-gray-100 dark:hover:bg-gray-900 transition {isWindows
? 'cursor-pointer'
: 'cursor-[w-resize]'}"
on:click={() => {
on:click={async () => {
showSidebar.set(!$showSidebar);
await tick();
openSidebarButton?.focus();
}}
aria-label={$showSidebar ? $i18n.t('Close Sidebar') : $i18n.t('Open Sidebar')}
>