mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-20 00:11:27 +00:00
fix: close modal shortcut closes only the top modal (#29830)
This commit is contained in:
parent
12b14124b9
commit
e4d65d0351
5 changed files with 29 additions and 9 deletions
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
import { onMount, getContext, createEventDispatcher, onDestroy, tick } from 'svelte';
|
||||
import * as FocusTrap from 'focus-trap';
|
||||
import { settings } from '$lib/stores';
|
||||
import { matchKeybinding, Shortcut } from '$lib/shortcuts';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
const dispatch = createEventDispatcher();
|
||||
|
|
@ -45,7 +47,10 @@
|
|||
};
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') {
|
||||
if (
|
||||
event.key === 'Escape' ||
|
||||
($settings?.keyboardShortcuts !== false && matchKeybinding(event) === Shortcut.CLOSE_MODAL)
|
||||
) {
|
||||
cancelHandler();
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +118,7 @@
|
|||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<div
|
||||
bind:this={modalElement}
|
||||
class=" fixed top-0 right-0 left-0 bottom-0 bg-black/60 w-full h-screen max-h-[100dvh] flex justify-center z-99999999 overflow-hidden overscroll-contain"
|
||||
class="modal fixed top-0 right-0 left-0 bottom-0 bg-black/60 w-full h-screen max-h-[100dvh] flex justify-center z-99999999 overflow-hidden overscroll-contain"
|
||||
in:fade={{ duration: 10 }}
|
||||
on:mousedown={() => {
|
||||
cancelHandler();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
import { onDestroy, onMount } from 'svelte';
|
||||
import { flyAndScale } from '$lib/utils/transitions';
|
||||
import { fade, fly, slide } from 'svelte/transition';
|
||||
import { settings } from '$lib/stores';
|
||||
import { matchKeybinding, Shortcut } from '$lib/shortcuts';
|
||||
|
||||
export let show = false;
|
||||
export let className = '';
|
||||
|
|
@ -12,7 +14,12 @@
|
|||
let mounted = false;
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape' && isTopModal()) {
|
||||
if (
|
||||
(event.key === 'Escape' ||
|
||||
($settings?.keyboardShortcuts !== false &&
|
||||
matchKeybinding(event) === Shortcut.CLOSE_MODAL)) &&
|
||||
isTopModal()
|
||||
) {
|
||||
console.log('Escape');
|
||||
show = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
const { saveAs } = fileSaver;
|
||||
|
||||
import { WEBUI_BASE_URL } from '$lib/constants';
|
||||
import { settings } from '$lib/stores';
|
||||
import { matchKeybinding, Shortcut } from '$lib/shortcuts';
|
||||
import PanzoomContainer from '$lib/components/common/PanzoomContainer.svelte';
|
||||
import XMark from '$lib/components/icons/XMark.svelte';
|
||||
|
||||
|
|
@ -18,7 +20,10 @@
|
|||
let previewElement = null;
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') {
|
||||
if (
|
||||
event.key === 'Escape' ||
|
||||
($settings?.keyboardShortcuts !== false && matchKeybinding(event) === Shortcut.CLOSE_MODAL)
|
||||
) {
|
||||
console.log('Escape');
|
||||
show = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
import { flyAndScale } from '$lib/utils/transitions';
|
||||
import * as FocusTrap from 'focus-trap';
|
||||
import { settings } from '$lib/stores';
|
||||
import { matchKeybinding, Shortcut } from '$lib/shortcuts';
|
||||
export let show = true;
|
||||
export let size = 'md';
|
||||
export let containerClassName = 'p-3';
|
||||
|
|
@ -40,7 +42,12 @@
|
|||
};
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape' && isTopModal()) {
|
||||
if (
|
||||
(event.key === 'Escape' ||
|
||||
($settings?.keyboardShortcuts !== false &&
|
||||
matchKeybinding(event) === Shortcut.CLOSE_MODAL)) &&
|
||||
isTopModal()
|
||||
) {
|
||||
console.log('Escape');
|
||||
show = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -328,10 +328,6 @@
|
|||
console.log('Shortcut triggered: SHOW_SHORTCUTS');
|
||||
event.preventDefault();
|
||||
showSettings.set('shortcuts');
|
||||
} else if (shortcut === Shortcut.CLOSE_MODAL) {
|
||||
console.log('Shortcut triggered: CLOSE_MODAL');
|
||||
event.preventDefault();
|
||||
showSettings.set(false);
|
||||
} else if (shortcut === Shortcut.OPEN_MODEL_SELECTOR) {
|
||||
console.log('Shortcut triggered: OPEN_MODEL_SELECTOR');
|
||||
event.preventDefault();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue