Description
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 😍