Skip to content

Commit 4c24873

Browse files
committed
Prevent outer form submission when submitting form in dialog
1 parent 0f3b4ab commit 4c24873

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/components/SecretsTable/EditSecretDialog.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,20 @@ export const EditSecretDialog: FC<EditSecretDialogProps> = ({
7272
onOpenChange(false)
7373
}
7474

75+
function handleFormSubmit(e: React.FormEvent<HTMLFormElement>) {
76+
e.preventDefault()
77+
e.stopPropagation()
78+
form.handleSubmit(onSubmit)(e)
79+
}
80+
7581
return (
7682
<Dialog open={open} onOpenChange={handleDialogOpenChange}>
7783
<DialogContent className="sm:max-w-[425px]">
7884
<DialogHeader>
7985
<DialogTitle>Edit secret</DialogTitle>
8086
</DialogHeader>
8187
<DialogDescription className="mb-6">Please provide a new secret value.</DialogDescription>
82-
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
88+
<form onSubmit={handleFormSubmit} className="space-y-6">
8389
<InputFormField control={form.control} name="name" label="Name" disabled />
8490

8591
<InputFormField control={form.control} name="value" label="Value" type="password" />

0 commit comments

Comments
 (0)