react-hook-form: issue with clear array errors in FieldArray

When “errors” is empty the array is not been removed in “errors” object

Steps to reproduce the behavior:

  1. remove value from the first input
  2. submit button should be disabled
  3. enter “10” to the first input
  4. submit button still disabled
  5. look at console.log(errors);. We still have an array in “errors” object

Expected behavior submit button should be active

Codesandbox link https://codesandbox.io/embed/react-hook-validate-trigger-sb1lj?fontsize=14&hidenavigation=1&theme=dark

discussion on spectrum https://spectrum.chat/react-hook-form/help/strange-validation-behavior-for-fields-array~b6982a9b-25f3-4fc7-adf5-cd3e1f5a27f7

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I didn’t find anything else.

Oh, look at this case:

  1. Append a second item
  2. Append a third item
  3. Make onBlur for the second item
  4. Make onBlur for the third item
  5. Click on Delete for the SECOND item
  6. Click on Delete for the third item IsValid is false

But if you replace 5 and 6 steps, like 5. Click on Delete for the THIRD item 6. Click on Delete for the second item all looks good

Awesome thanks a lot, I will patch that issue tonight. ❤️

@bluebill1049 look at this example https://codesandbox.io/s/formstate-is-not-still-valid-after-removing-items-ycu19

  1. Append two items
  2. make “onBlur” for both new items
  3. Remove second and third items

Result formState.isValid is still false. errors object contains test: [undefined]

hey @DisaPadla you can install this beta on the CSB (ignore the drop down, just click install) 😃 make sure point to ‘react-hook-form’ instead of ‘./src’ folder.