mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-29 08:31:48 -05:00
fix(a11y): the sidebar can be resized from the keyboard (#33440)
This commit is contained in:
1 file changed
+16
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user