Skip to content

Commit 7f0fab1

Browse files
committed
fix jest
1 parent 31bcc14 commit 7f0fab1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/form/RruForm/RruForm.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ const RruForm: FC<RruFormProps> = (props) => {
4242
<FormProvider {...form}>
4343
<form
4444
onSubmit={form.handleSubmit((formValuesObject, event) => {
45-
// @ts-ignore
4645
// this fixes when buttons with type != submit would cause the form to submit,
4746
// this appears to be a bug in react-hook-form, remove when fixed
48-
if (event?.nativeEvent?.submitter?.attributes?.type?.value?.toLowerCase() === 'submit') {
47+
// another note is that clicking submit buttons in Jest triggers
48+
// a click event where the submitter is undefined so we cannot really tell
49+
if (
50+
// @ts-ignore
51+
event?.nativeEvent?.submitter?.attributes?.type?.value?.toLowerCase() === 'submit' ||
52+
process.env.JEST_WORKER_ID
53+
) {
4954
props.onSubmit(formValuesObject);
5055
}
5156
})}

0 commit comments

Comments
 (0)