Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialValues being reset causing dirty to be incorrect (v2.1.4 regression) #2292

Closed
jamesmosier opened this issue Feb 18, 2020 · 0 comments
Closed

Comments

@jamesmosier
Copy link
Contributor

jamesmosier commented Feb 18, 2020

🐛 Bug report

Current Behavior

As of v2.1.4, initialValues cannot be counted on to not change during the duration of a page load. These lines introduced in v2.1.4 will now update initialValues anytime the props.initialValues changes. Therefore if I have an application and the initialValues I pass in happen to change then Formik will update that in its internal state and therefore when doing things like determining if a form is dirty it can report unexpected results.

Expected behavior

I would expect once I pass in initialValues for those to be set throughout the life of the page (as this is how it has worked previously).

Reproducible example

https://codesandbox.io/s/formik-v214-dirty-breaking-2y6ho

  1. Input a single letter into the name field (dirty = true)
  2. Input a single letter into the email field (dirty = true)
  3. Then remove (backspace) the value you just entered in the email field.
  4. Notice that in Formik state dirty = false because initialValues are equal to values.

If you switch the Formik version back to 2.1.3 the above test case end with dirty = true in step 4.

Suggested solution(s)

Remove this code which was introduced in the 2.1.4 release. It was introduced via #2205

Additional context

If this new functionality is to be expected and desired then I believe this should be a new minor version bump since it is a breaking change.

Your environment

Software Version(s)
Formik 2.1.4
React 16.11.0
TypeScript n/a
Browser Chrome 80
npm/Yarn Yarn
Operating System Mac OS
@jamesmosier jamesmosier changed the title initialValues being reset causing dirty to be incorrect (v2.1.4 bug) initialValues being reset causing dirty to be incorrect (v2.1.4 regression) Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant