final-form / final-form-arrays

Array Mutators for 🏁 Final Form
https://final-form.org/arrays
MIT License
70 stars 40 forks source link

Fixed bug with deleting rows with validators #65

Open Nikola-Andreev opened 3 years ago

Nikola-Andreev commented 3 years ago

Consider the following situation:

  1. Lets say initially you have 1 row in the form array.
  2. Add one new row to the form.
  3. Delete the first one (now you are in trouble if you have validators).

Problems:

  1. If you have attached validator to the field, your validator is not updated to point to the validator on index 0! So if you pass additional data to the validator (like index for example), the index is not updated!
  2. If you have attached validateFields to the field to optimize the validator calls - (BOOM), you receive an error.

Check out the following example for more details. Try the firstName field and watch the console: https://codesandbox.io/s/array-fields-forked-lb9v0?file=/src/App.js

codecov[bot] commented 3 years ago

Codecov Report

Merging #65 (ce1e5a9) into master (4a65647) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #65   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        15           
  Lines          165       165           
  Branches        36        36           
=========================================
  Hits           165       165           
Impacted Files Coverage Δ
src/moveFieldState.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4a65647...3825ce6. Read the comment docs.