fix: pressing enter in a modal now trigger the submission

This commit is contained in:
Arman committed 2025-01-21 14:32:10 +01:00
1 parent 0cf9fcef47
commit 6a1dd88b24
1 file changed
+11 -1
+11 -1
View File
@@ -19,11 +19,19 @@
export let hideFooter = false;
let alert: HTMLElement;
let formComponent: Form;
beforeNavigate(() => {
show = false;
});
function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Enter') {
event.preventDefault();
formComponent.triggerSubmit();
}
}
$: $disableCommands(show);
$: if (error) {
@@ -31,7 +39,9 @@
}
</script>
<Form isModal {onSubmit}>
<svelte:window on:keydown={handleKeydown} />
<Form isModal {onSubmit} bind:this={formComponent}>
<Modal {title} bind:open={show} {hideFooter}>
<svelte:fragment slot="description">
<slot name="description" />