Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thirty-coins-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

The login form input data will no longer reset on a failed login attempt.
10 changes: 8 additions & 2 deletions core/vibes/soul/sections/sign-in-section/sign-in-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { getFormProps, getInputProps, SubmissionResult, useForm } from '@conform-to/react';
import { getZodConstraint, parseWithZod } from '@conform-to/zod';
import { useActionState, useEffect } from 'react';
import { startTransition, useActionState, useEffect } from 'react';
import { useFormStatus } from 'react-dom';

import { FormStatus } from '@/vibes/soul/form/form-status';
Expand Down Expand Up @@ -37,6 +37,12 @@ export function SignInForm({
constraint: getZodConstraint(schema),
shouldValidate: 'onBlur',
shouldRevalidate: 'onInput',
onSubmit(event, { formData }) {
event.preventDefault();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍹 I could be wrong, but I think preventDefault() allows us to remove the action={formAction} attribute on the form element below. Since we're now calling it here in onSubmit, I think the action prop is redundant. Double check me on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to remove passing the action!

startTransition(() => {
formAction(formData);
});
},
onValidate({ formData }) {
return parseWithZod(formData, { schema });
},
Expand Down Expand Up @@ -70,7 +76,7 @@ export function SignInForm({
};

return (
<form {...getFormProps(form)} action={formAction} className="flex grow flex-col gap-5">
<form {...getFormProps(form)} className="flex grow flex-col gap-5">
<Input
{...getInputProps(fields.email, { type: 'text' })}
errors={fields.email.errors}
Expand Down