-
-
Notifications
You must be signed in to change notification settings - Fork 501
Description
Describe the bug
When a user pushes a field using field.pushValue or form.pushFieldValue, errors for the subfields are missing from fieldMeta.
This leads to a really bad state if the new subfield has errors on the form level schema. canSubmit becomes false so they can't submit the form, yet the error cannot be surfaced.
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-form-lntbeysv?file=src%2Findex.tsx
Steps to reproduce
- Add a row
- Notice canSubmit is now false, yet no error is surfaced
- Click "Log all errors" notice that the form has the errors, but is missing from the fieldMeta
Expected behavior
In the UI, I would expect the error is immediately surfaced to the user.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
See StackBlitz, latest version of TSF, valid TS version
TanStack Form adapter
react-form
TanStack Form version
^1.7.0
TypeScript version
No response
Additional context
This happens because we run the validator before the new pushed subfields mount. Since they have not mounted fieldMeta does not exist leading to the difference between the errorMap on the form and field level.
I propose that onMount we always check if the form errorMap contains errors for the field. If so, copy it over.