fix(a11y): the sidebar can be resized from the keyboard (#33440)

This commit is contained in:
G30 authored and GitHub committed 2026-10-31 07:50:12 +09:00
1 parent c9ee89467e
commit d11a5f0f03
1 file changed
+16
+16
View File
@@ -763,6 +763,15 @@
document.documentElement.style.setProperty('--sidebar-width', `${newSidebarWidth}px`);
};
const resizeKeyHandler = (e: KeyboardEvent) => {
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
e.preventDefault();
const delta = e.key === 'ArrowLeft' ? -10 : 10;
sidebarWidth.set(Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, ($sidebarWidth ?? 245) + delta)));
localStorage.setItem('sidebarWidth', String($sidebarWidth));
};
onDestroy(() => {
if (isResizing) {
document.body.style.userSelect = '';
@@ -1958,7 +1967,14 @@
class="relative flex items-center justify-center group border-r border-gray-50 dark:border-gray-850/30 hover:border-gray-200 dark:hover:border-gray-800 transition z-20 bg-transparent p-0 appearance-none"
id="sidebar-resizer"
on:pointerdown={resizeStartHandler}
on:keydown={resizeKeyHandler}
role="separator"
tabindex="0"
aria-label={$i18n.t('Resize panel')}
aria-orientation="vertical"
aria-valuenow={$sidebarWidth}
aria-valuemin={MIN_WIDTH}
aria-valuemax={MAX_WIDTH}
>
<div
class=" absolute -left-1.5 -right-1.5 -top-0 -bottom-0 z-20 cursor-col-resize bg-transparent"