File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -42,10 +42,15 @@ const RruForm: FC<RruFormProps> = (props) => {
42
42
< FormProvider { ...form } >
43
43
< form
44
44
onSubmit = { form . handleSubmit ( ( formValuesObject , event ) => {
45
- // @ts -ignore
46
45
// this fixes when buttons with type != submit would cause the form to submit,
47
46
// 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
+ ) {
49
54
props . onSubmit ( formValuesObject ) ;
50
55
}
51
56
} ) }
You can’t perform that action at this time.
0 commit comments