mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-30 08:55:12 -05:00
fix(a11y): drawers keep keyboard focus inside and are announced as dialogs (#33547)
This commit is contained in:
10 files changed
+77
-39
No files matched your search
@@ -2,7 +2,6 @@
|
||||
import { getContext, onDestroy } from 'svelte';
|
||||
import { beforeNavigate, goto } from '$app/navigation';
|
||||
import { mobile } from '$lib/stores';
|
||||
import { createFocusTrap } from 'focus-trap';
|
||||
import Files from './Files.svelte';
|
||||
import FileViewer from './FileViewer.svelte';
|
||||
import AddContentMenu from './AddContentMenu.svelte';
|
||||
@@ -89,11 +88,6 @@
|
||||
goto(navigation.to!.url.href).finally(() => (allowNavigation = false));
|
||||
});
|
||||
});
|
||||
const trapFocus = (node: HTMLElement) => {
|
||||
const trap = createFocusTrap(node, { escapeDeactivates: false });
|
||||
trap.activate();
|
||||
return { destroy: () => trap.deactivate() };
|
||||
};
|
||||
onDestroy(() => clearTimeout(debounce));
|
||||
</script>
|
||||
|
||||
@@ -123,15 +117,12 @@
|
||||
resizerId="knowledge-files-resizer">{@render sidebar()}</ResizableSidePanel
|
||||
>{@render viewer()}{/if}
|
||||
</div>
|
||||
{#if $mobile}<Drawer show={drawerOpen} className="h-full" onRequestClose={close}
|
||||
><div
|
||||
class="h-full"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={$i18n.t('File preview')}
|
||||
tabindex="-1"
|
||||
use:trapFocus
|
||||
>
|
||||
{#if $mobile}<Drawer
|
||||
show={drawerOpen}
|
||||
className="h-full"
|
||||
ariaLabel={$i18n.t('File preview')}
|
||||
onRequestClose={close}
|
||||
><div class="h-full">
|
||||
{@render viewer()}
|
||||
</div></Drawer
|
||||
>{/if}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import { onDestroy, getContext, tick, type Snippet } from 'svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { copyToClipboard } from '$lib/utils';
|
||||
import { createFocusTrap } from 'focus-trap';
|
||||
import { mobile } from '$lib/stores';
|
||||
import Drawer from '$lib/components/common/Drawer.svelte';
|
||||
import ResizableSidePanel from '$lib/components/common/ResizableSidePanel.svelte';
|
||||
@@ -181,16 +180,7 @@
|
||||
value = content;
|
||||
flush();
|
||||
};
|
||||
const fileDrawer = (node: HTMLElement) => {
|
||||
const trap = createFocusTrap(node, { escapeDeactivates: false });
|
||||
trap.activate();
|
||||
return {
|
||||
destroy: () => {
|
||||
flush();
|
||||
trap.deactivate();
|
||||
}
|
||||
};
|
||||
};
|
||||
const fileDrawer = () => ({ destroy: flush });
|
||||
$: if (!$mobile) showFileDrawer = false;
|
||||
$: if (loadedPath && value !== loadedValue && !readOnly) {
|
||||
dirty = true;
|
||||
@@ -570,15 +560,8 @@
|
||||
</div>
|
||||
|
||||
{#if $mobile}
|
||||
<Drawer bind:show={showFileDrawer} className="h-full" onClose={flush}>
|
||||
<div
|
||||
class="h-full"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={selected}
|
||||
tabindex="-1"
|
||||
use:fileDrawer
|
||||
>
|
||||
<Drawer bind:show={showFileDrawer} className="h-full" ariaLabel={selected} onClose={flush}>
|
||||
<div class="h-full" use:fileDrawer>
|
||||
{@render fileContent()}
|
||||
</div>
|
||||
</Drawer>
|
||||
|
||||
Reference in new issue
Block a user