Skip to content

Commit

Permalink
fix: perform field reset before all values reset closes #3934
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Sep 19, 2022
1 parent b2bfdee commit 1c016d9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/vee-validate/src/useForm.ts
Expand Up @@ -406,6 +406,10 @@ export function useForm<TValues extends Record<string, any> = Record<string, any
*/
function resetForm(state?: Partial<FormState<TValues>>) {
RESET_LOCK = true;

// Reset all field states first
mutateAllFields(f => f.resetField());

// set initial values if provided
if (state?.values) {
setInitialValues(state.values);
Expand All @@ -417,9 +421,6 @@ export function useForm<TValues extends Record<string, any> = Record<string, any
setValues(originalInitialValues.value);
}

// avoid resetting the field values, because they should've been reset already.
mutateAllFields(f => f.resetField());

if (state?.touched) {
setTouched(state.touched);
}
Expand Down

0 comments on commit 1c016d9

Please sign in to comment.