react-final-form-arrays icon indicating copy to clipboard operation
react-final-form-arrays copied to clipboard

Bug - deleting row

Open omerman opened this issue 4 years ago • 4 comments

Assuming we render the array with editable items, like so, {fields.map((arrPrefix) => <Field name={${arrPrefix}.val1} />}

When deleting a row of a field array all of the indexes following the row becomes dirty, in the form.dirtyFields.

I think it happens because the Field component of say item[1].val1 isEqual will return false once deleting say item[0].val1. I think the isEqual should be different when the Field is looking at a nested array field, surely a change in Field would be wrong, but Im thinking there should at least be a FieldArrayCell that will render also accept id prop(along with Field props) and will use this to send the isEqual the correct values, and then, the isEqual will evaluate correctly, and form.dirtyFields will be correct.

omerman avatar Aug 07 '20 15:08 omerman

I stumbled upon the same problem. Have you found a solution @omerman ?

OnkelTem avatar Aug 28 '20 10:08 OnkelTem

@OnkelTem Instead of relying on the dirty fields for arrays with delete option.. I checked versus the initial values instead.. In my specific use cases it was enough.. But its not ideal..

omerman avatar Aug 28 '20 11:08 omerman

It's really irritating :(

ymoran00 avatar Jun 16 '21 17:06 ymoran00

It's really irritating :(

It is, but to fix it you'd have to have some breaking changes.. like enforce a unique Id for each row. It is possible.. but seems like a lot of work..

omerman avatar Jun 28 '21 08:06 omerman