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

Validation is no longer working on useFieldArray fields #5234

Closed
janhartmann opened this issue May 18, 2021 · 7 comments
Closed

Validation is no longer working on useFieldArray fields #5234

janhartmann opened this issue May 18, 2021 · 7 comments

Comments

@janhartmann
Copy link

janhartmann commented May 18, 2021

Describe the bug
After upgrading to 7.X we are now experiencing problems with validation of fields inside useFieldArray.

When adding a new row of fields, the form is invalid no matter if the fields has been filled out correctly. Removing the newly added row, makes the validation true. Only filling out the default row makes the form valid, however, adding two rows and remove the default one makes the form invalid.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/romantic-ptolemy-nlgcc?file=/src/App.tsx
  2. Fill out "Test" in "Name
  3. Fill out "1" in Field 1 and "2" in Field 2
  4. Notice the form is valid
  5. Click "Add Row"
  6. Notice the form is invalid
  7. Fill out "3" in Field 1 and "4" in Field 2
  8. Notice how the form stays invalid

Codesandbox link (Required)
https://codesandbox.io/s/romantic-ptolemy-nlgcc?file=/src/App.tsx

Expected behavior
The validation to form on dynamically added fields.

@bluebill1049 bluebill1049 added status: under investigation aware of this issue and pending for investigation bug Something isn't working labels May 18, 2021
bluebill1049 added a commit that referenced this issue May 18, 2021
@bluebill1049 bluebill1049 removed the status: under investigation aware of this issue and pending for investigation label May 18, 2021
@bluebill1049 bluebill1049 self-assigned this May 18, 2021
@janhartmann
Copy link
Author

janhartmann commented May 19, 2021

I just tried upgrading, and the bug is still there. When adding a new list of fields, the form becomes invalid. Go to https://codesandbox.io/s/romantic-ptolemy-nlgcc?file=/src/App.tsx and change the version to 7.6.2

@bluebill1049 bluebill1049 reopened this May 19, 2021
@bluebill1049 bluebill1049 added status: under investigation aware of this issue and pending for investigation and removed bug Something isn't working labels May 19, 2021
@bluebill1049
Copy link
Member

Screen.Recording.2021-05-19.at.9.14.25.pm.mov

can you share steps to reproduce the issue? (I followed the issue steps)

@janhartmann
Copy link
Author

Hi again, I have a hard time reproducing it, but it still fails in my application. Only thing I wonder is that when I add a new row, it becomes invalid because there is a null in the dirty fields?

https://codesandbox.io/s/romantic-ptolemy-nlgcc?file=/src/App.tsx

See the pre at the bottom.

@bluebill1049
Copy link
Member

Thanks @janhartmann i will try again later this weekend, see if I can reproduce this issue. if anyone else having a similar issue, please help to reproduce the problem.

@janhartmann
Copy link
Author

janhartmann commented May 20, 2021

I was able to solve my problem in my application by not using a <Controller> around my input field (but registering directly on the input). I dont know if that helps you in any way, but I wanted to let you know. Thanks for an excellent library by the way.

@bluebill1049
Copy link
Member

Thanks @janhartmann interesting... i will take a deeper look this weekend anyhow.

@bluebill1049
Copy link
Member

Couldn't reproduce the issue... I am attaching a unit test for this, and feel free to follow me (anyone) up on this issue, if whoever can reproduce it in a codesandbox.

@bluebill1049 bluebill1049 removed the status: under investigation aware of this issue and pending for investigation label May 26, 2021
@bluebill1049 bluebill1049 removed their assignment Aug 12, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants