Skip to content

All Fields become dirty when unshifting if initialValues are present #33

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

Open
tatchi opened this issue Jun 9, 2018 · 0 comments
Open

Comments

@tatchi
Copy link

tatchi commented Jun 9, 2018

Are you submitting a bug report or a feature request?

I think it's a bug (but might be simply a wrong behavior from my point of view)

What is the current behavior?

All the already existing values (fields) within the FieldArray become dirty when we add a value to the beginning of the array (with unshift or insert functions). It does occur only in case of an initialValues prop is provided to the Form component. If no initialValues is provided, adding a new value does not set the already existing ones as dirty.

Furthermore, this does not occur if adding a value at the end of the array.

What is the expected behavior?

Whatever method we use (push, unshift, insert) and to whatever index of the array we add the new value, the dirty state of the existing values should stay the same. The new value should not be dirty.

Sandbox Link

I used the 'Simple Example' from the doc and simply added a borderColor: orange style to the input if dirty.

  • Example with initialValues (just click on "Add customer" button) -> new value and existing ones become dirty: https://codesandbox.io/s/q1367y759. If you add multiple values, it becomes even more inconsistent.

  • Same example but without initialValues (works fine): https://codesandbox.io/s/1rw4o33r37

  • With initialValues but now using the push method. If you add a value without removing anything, the new value is not dirty. But if first you remove a value (by clicking on "Remove Customer" button) and then click on "Add Customer" button, the new value is dirty: https://codesandbox.io/s/k9n9l1l1o5

What's your environment?

Same as in the example.

Other information

If it's indeed something to should be fixed, I would be happy to help out (but will certainly need some guidance).

Thanks for the amazing work 😍

@tatchi tatchi changed the title All Fields become dirty when unshifting while initialValues are present All Fields become dirty when unshifting if initialValues are present Jun 9, 2018
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