Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
bf4dcc10
"vscode:/vscode.git/clone" did not exist on "8685699392cfaa79c9c9ab0e16fca49b0f0574f3"
Commit
bf4dcc10
authored
Jun 24, 2024
by
Timothy J. Baek
Browse files
fix: modal esc
parent
503d16f4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
src/lib/components/common/Modal.svelte
src/lib/components/common/Modal.svelte
+8
-3
No files found.
src/lib/components/common/Modal.svelte
View file @
bf4dcc10
...
@@ -23,12 +23,17 @@
...
@@ -23,12 +23,17 @@
};
};
const handleKeyDown = (event: KeyboardEvent) => {
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
if (event.key === 'Escape'
&& isTopModal()
) {
console.log('Escape');
console.log('Escape');
show = false;
show = false;
}
}
};
};
const isTopModal = () => {
const modals = document.getElementsByClassName('modal');
return modals.length && modals[modals.length - 1] === modalElement;
};
onMount(() => {
onMount(() => {
mounted = true;
mounted = true;
});
});
...
@@ -38,8 +43,8 @@
...
@@ -38,8 +43,8 @@
window.addEventListener('keydown', handleKeyDown);
window.addEventListener('keydown', handleKeyDown);
document.body.style.overflow = 'hidden';
document.body.style.overflow = 'hidden';
} else if (modalElement) {
} else if (modalElement) {
document.body.removeChild(modalElement);
window.removeEventListener('keydown', handleKeyDown);
window.removeEventListener('keydown', handleKeyDown);
document.body.removeChild(modalElement);
document.body.style.overflow = 'unset';
document.body.style.overflow = 'unset';
}
}
</script>
</script>
...
@@ -49,7 +54,7 @@
...
@@ -49,7 +54,7 @@
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
<div
bind:this={modalElement}
bind:this={modalElement}
class=" fixed top-0 right-0 left-0 bottom-0 bg-black/60 w-full min-h-screen h-screen flex justify-center z-[9999] overflow-hidden overscroll-contain"
class="
modal
fixed top-0 right-0 left-0 bottom-0 bg-black/60 w-full min-h-screen h-screen flex justify-center z-[9999] overflow-hidden overscroll-contain"
in:fade={{ duration: 10 }}
in:fade={{ duration: 10 }}
on:mousedown={() => {
on:mousedown={() => {
show = false;
show = false;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment