Skip to content

Commit 71a695e

Browse files
committed
fix: update shouldFocusError
1 parent abd3e07 commit 71a695e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/v2/logic/createForm.ts

+6
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,12 @@ const createForm = <TSchema>(props: ICreateFormProps<TSchema>) => {
668668
executeExpression();
669669

670670
if (hasError() && !options.forceSubmit) {
671+
if (props.shouldFocusError) {
672+
const name = Object.keys(_state.error)[0];
673+
setFocus(name);
674+
props.log?.(`trigger focus ${name}`);
675+
}
676+
671677
_state.containerFormState.isSubmitSuccessful = false;
672678
onInvalid?.(_state.values, _state.error, "ON-SCHEMA", _state);
673679
} else {

0 commit comments

Comments
 (0)