Skip to content

Commit 9dd36bd

Browse files
joe-shajanzomars
andauthored
fix: signup form submiting after api error (#8298)
Co-authored-by: Omar López <[email protected]>
1 parent b140435 commit 9dd36bd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

apps/web/pages/signup.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,17 @@ export default function Signup({ prepopulateFormValues }: inferSSRProps<typeof g
9595
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
9696
<div className="bg-default mx-2 px-4 py-8 shadow sm:rounded-lg sm:px-10">
9797
<FormProvider {...methods}>
98-
<form onSubmit={methods.handleSubmit(signUp)} className="bg-default space-y-6">
98+
<form
99+
onSubmit={(event) => {
100+
event.preventDefault();
101+
event.stopPropagation();
102+
103+
if (methods.formState?.errors?.apiError) {
104+
methods.clearErrors("apiError");
105+
}
106+
methods.handleSubmit(signUp)(event);
107+
}}
108+
className="bg-default space-y-6">
99109
{errors.apiError && <Alert severity="error" message={errors.apiError?.message} />}
100110
<div className="space-y-2">
101111
<TextField

0 commit comments

Comments
 (0)