Skip to content

Commit

Permalink
Prevent modals from closing for first second after opening
Browse files Browse the repository at this point in the history
  • Loading branch information
Iapetus-11 committed Nov 28, 2024
1 parent 956f4b0 commit ac1b6fc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,27 @@
close: [];
}>();
const shownTime = performance.now();
function close() {
// Prevent modal closing for first second, in case they're spamming
if ((performance.now() - shownTime) >= 1000) {
emit('close');
}
}
const dialog = ref<HTMLDialogElement>();
const innerContainer = ref<HTMLElement>();
async function onWindowClick(ev: MouseEvent) {
if (ev.target instanceof HTMLElement && !innerContainer.value!.contains(ev.target)) {
emit('close');
close();
}
}
function onWindowKeyPress(ev: KeyboardEvent) {
if (ev.key === 'Escape') {
emit('close');
close();
}
}
Expand Down

0 comments on commit ac1b6fc

Please sign in to comment.