Skip to content

Commit

Permalink
fix: prevent re-submitting the form while it's being submitted
Browse files Browse the repository at this point in the history
  • Loading branch information
inigomarquinez committed Jan 30, 2024
1 parent 8686d87 commit d67c0fa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ const FormBuilder = ({
}

const onSubmit = async (data) => {
if (isLoading) return
onSubmitForm(await formatData(data))
}

Expand All @@ -303,7 +304,8 @@ const FormBuilder = ({
variant:
form && form.layout
? 'forms.container.' + (form && form.layout)
: 'forms.container'
: 'forms.container',
pointerEvents: isLoading ? 'none' : 'auto'
}}
onSubmit={useFormObj.handleSubmit(onSubmit)}
{...props}
Expand Down Expand Up @@ -339,6 +341,7 @@ const FormBuilder = ({
<Button
sx={styles.fitContent}
key={cfa.caption}
disabled={isLoading}
isLoading={isLoading}
id={cfa.id}
caption={cfa.caption}
Expand Down

0 comments on commit d67c0fa

Please sign in to comment.