diff --git a/packages/form-core/src/FormApi.ts b/packages/form-core/src/FormApi.ts index d285016ec..385d1fa75 100644 --- a/packages/form-core/src/FormApi.ts +++ b/packages/form-core/src/FormApi.ts @@ -251,6 +251,7 @@ export class FormApi { this.store.setState((prev) => ({ ...prev, isValidating: true, + isFormValidating: true, formValidationCount: prev.formValidationCount + 1, })) @@ -274,6 +275,7 @@ export class FormApi { this.store.setState((prev) => ({ ...prev, isValidating: false, + isFormValidating: false, formError: error ? 'Invalid Form Values' : false, })) @@ -400,14 +402,14 @@ export class FormApi { })) } - this.validateForm() - this.store.setState((prev) => { return { ...prev, values: setBy(prev.values, field, updater), } }) + + this.validateForm() }) } diff --git a/packages/form-core/src/tests/FormApi.spec.ts b/packages/form-core/src/tests/FormApi.spec.ts index 6010a0f87..a6cfd05ac 100644 --- a/packages/form-core/src/tests/FormApi.spec.ts +++ b/packages/form-core/src/tests/FormApi.spec.ts @@ -344,7 +344,9 @@ describe('form api', () => { expect(form.state.canSubmit).toBe(false) field.handleChange('ayo') - await sleep(11) + await sleep(1) + expect(form.state.isFormValidating).toBe(true) + await sleep(9) expect(form.state.isFormValidating).toBe(false) expect(form.state.isFormValid).toBe(true)