-
-
Notifications
You must be signed in to change notification settings - Fork 71
Using "remove" on an array row is not making form dirty #56
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
Comments
This is a The culprit is this line: https://github.com/final-form/react-final-form-arrays/blob/master/src/FieldArray.js#L72 If you do not pass in your custom On a site note: using the mutators never marks the |
We just confirmed this issue, and implemented isEquals as the combination length/identity check. I think it would be better if FieldsArray isEquals(a, b) {
if (a.length != b.length) return false
let isEquals = this.props.isEquals || ((a, b) => a === b)
for (let i=0; i < a.length; i++) {
if (isEquals(a[i], b[i])) return false
}
return true
} |
Quoting @ncphillips
May I ask if @erikras agrees too? Is this considered a bug, and will it ever be fixed? Many thanks. |
A fix for this bug would be really awesome 🙏 |
@VincentCharpentier Depending on your use-case this should be fixed in the newer version. |
Yeah, I think this is fixed now. The |
I can confirm this is fixed with these versions:
|
Are you submitting a bug report or a feature request?
bug report
What is the current behavior?
Have a form that has a FieldArray in it. The form has initialValues set for the array.
If you use field.remove(index) to remove a row from the FieldArray, it does not make the parent form dirty.
This is an issue where the disabled of the submit button on the form is tied to "pristine".
The final form documentation at https://github.com/final-form/react-final-form-arrays#simple-example has a link to a codesandbox at https://codesandbox.io/s/kx8qv67nk5.
In this example, if you insert the following in the
<Form>
tag:initialValues={{ company: 'MinuteMe.com', customers: [ { firstName: 'Simon', lastName: 'Steele' } ] }}
You will see the form Submit button is immediately disabled - form is pristine.
Delete the Customer row, and form becomes dirty - Submit button is enabled.
NOW... This sandbox uses old versions of the libraries.
I am using newer versions, per this sandbox https://codesandbox.io/s/p34l93w81j. NOTE this sandbox already has my initialValues entered.
See that the same outcome is not achieved by deleting the row! The form is still dirty even though the row was removed.
What is the expected behavior?
Expected behaviour is that the form should be marked 'dirty' when the array row is removed.
Sandbox Link
See above.
What's your environment?
The version that fails (per sandbox link above):
"react-final-form-arrays": "1.1.0",
"react-final-form": "3.6.7",
"react-dom": "16.6.0",
"react": "16.6.0",
"final-form-arrays": "1.1.0",
"final-form": "4.10.0"
The text was updated successfully, but these errors were encountered: