Repro of issues on stackblitz: Issue 1 Toggle 'show people' to true Add a couple of people with no name Press submit and receive errors Toggle 'show people' to false (this sets the people array back to []) Still can't submit Toggle 'show people' back to true Add people and see the errors are still present
Issue 2 Toggle 'show people' to true Add 2 people Add a name for the second person Toggle 'show people' to false Submit - note submit fails for value being undefined for the field you had a name in (you can try adding
value?.trim
value?.trim
for the validation, but this will actually give you an error that name is required for the field you actually entered a value for!)
---
I have a form where there are toggles that should reset the hidden fields or at least not check validation on those hidden fields so the form can submit. Conditionally rendering these fields does not seem to matter, which is fine but I seem to be running into issues such as the above when trying to work around it.