Skip to content

Commit

Permalink
fix: clone values before reset closes #4536
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Nov 18, 2023
1 parent 6684a0f commit 2abb896
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/shaggy-humans-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vee-validate': patch
---

fix: clone values before reset closes #4536
2 changes: 1 addition & 1 deletion packages/vee-validate/src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ export function useForm<
* Resets all fields
*/
function resetForm(resetState?: Partial<FormState<TValues>>, opts?: ResetFormOpts) {
let newValues = resetState?.values ? resetState.values : originalInitialValues.value;
let newValues = deepCopy(resetState?.values ? resetState.values : originalInitialValues.value);
newValues = isTypedSchema(schema) && isCallable(schema.cast) ? schema.cast(newValues) : newValues;
setInitialValues(newValues);
mutateAllPathState(state => {
Expand Down

0 comments on commit 2abb896

Please sign in to comment.