You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 withinitialValues (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.
WithinitialValues 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 😍
The text was updated successfully, but these errors were encountered:
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
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 (withunshift
orinsert
functions). It does occur only in case of aninitialValues
prop is provided to theForm
component. If noinitialValues
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/1rw4o33r37With
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/k9n9l1l1o5What'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 😍
The text was updated successfully, but these errors were encountered: