Skip to content

Commit

Permalink
fix: update shouldFocusError
Browse files Browse the repository at this point in the history
  • Loading branch information
adyfk committed Jul 31, 2023
1 parent abd3e07 commit 71a695e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/v2/logic/createForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,12 @@ const createForm = <TSchema>(props: ICreateFormProps<TSchema>) => {
executeExpression();

if (hasError() && !options.forceSubmit) {
if (props.shouldFocusError) {
const name = Object.keys(_state.error)[0];
setFocus(name);
props.log?.(`trigger focus ${name}`);
}

_state.containerFormState.isSubmitSuccessful = false;
onInvalid?.(_state.values, _state.error, "ON-SCHEMA", _state);
} else {
Expand Down

0 comments on commit 71a695e

Please sign in to comment.