Skip to content
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

Fixed bug with deleting rows with validators #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Nikola-Andreev
Copy link

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
Copy link

codecov bot commented Jan 23, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant