T
TanStack2y ago
sensitive-blue

Field array validation not working correctly when field is removed

When a field array field is removed with a validation error on it, the field array that was +1 in the array shows the removed field's validation error, even tho the field previously did not have validation errors. It seems as tho validation is not running properly after an element is removed from the field array. I tried to call form.validateAllFields() after removing an element from the field array, but that leads to Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'errorMap') being thrown and not caught. Any advice on this?
6 Replies
sensitive-blue
sensitive-blueOP2y ago
I'm able to prevent the error being thrown if I delay the time between removing the field and calling validateAllFields with a setTimeout but that feels like a bad hack
adverse-sapphire
adverse-sapphire2y ago
Hi! ☺️ This could be a bug... 🤔 Could you open an issue with a minimal StackBlitz repro in the form's repo (https://github.com/TanStack/form/issues) ? It'd be really helpful 🙏
GitHub
Issues · TanStack/form
🤖 Powerful and type-safe form state management for the web. TS/JS, React Form, Solid Form, Svelte Form and Vue Form. - Issues · TanStack/form
sensitive-blue
sensitive-blueOP2y ago
Can do!
sensitive-blue
sensitive-blueOP2y ago
GitHub
Field Array Validation Not Refreshing Properly When Field is Remove...
Describe the bug When multiple fields are added to a field array, and there is validation errors, if you update one of these fields to not have a validation error, and remove a field with a validat...
adverse-sapphire
adverse-sapphire2y ago
Thanks for the report, I'll check out the issue later this week! ☺️
sensitive-blue
sensitive-blueOP2y ago
Thanks very much!

Did you find this page helpful?