Skip to content

Commit

Permalink
Merge pull request #30 from stevent-team/fix/validation-on-reset
Browse files Browse the repository at this point in the history
Fix validation on change running after a reset
  • Loading branch information
GRA0007 authored Aug 1, 2023
2 parents d3fe310 + 4ac5aa9 commit a877d11
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fast-dogs-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@stevent-team/react-zoom-form": patch
---

Disable validation on change after a reset until the next submit event
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# React Zoom Form <img width="400" align="right" src="https://github.com/stevent-team/react-zoom-form/assets/16392483/e7898088-ccfc-4899-9f35-a32faaf8964c" alt="car">
# React Zoom Form <img width="300" align="right" src="https://github.com/stevent-team/react-zoom-form/assets/16392483/e7898088-ccfc-4899-9f35-a32faaf8964c" alt="car">

[![npm version](https://img.shields.io/npm/v/@stevent-team/react-zoom-form)](https://www.npmjs.com/package/@stevent-team/react-zoom-form)
[![minzip size](https://img.shields.io/bundlephobia/minzip/@stevent-team/react-zoom-form)](https://bundlephobia.com/package/@stevent-team/react-zoom-form)
Expand Down
1 change: 1 addition & 0 deletions lib/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const useForm = <Schema extends z.AnyZodObject>({
const isDirty = useMemo(() => !deepEqual(formValue, internalInitialValues), [formValue, internalInitialValues])

const reset = useCallback<UseFormReturn<Schema>['reset']>((values = initialValues) => {
setValidateOnChange(false)
setInternalInitialValues(values)
setFormValue(values)
}, [initialValues])
Expand Down

0 comments on commit a877d11

Please sign in to comment.