Form-level validation with onChange and arrays throws an undefined errorMap
Open
Nobody has claimed this yet.
v1
v2: needs investigation
- Dominant language
- TypeScript
- Stars
- 6.7k
- Forks
- 682
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 7
Description
Describe the bug
Form-level validation with onChange and arrays throws an undefined errorMap when all fields are deleted or when a single field is removed. This issue only occurs with form-level validation using the onChange validator.
Uncaught TypeError: Cannot read properties of undefined (reading 'errorMap')
at @tanstack_react-form.js?v=473e5c45:1136:27
at functionalUpdate (@tanstack_react-form.js?v=473e5c45:423:42)
at @tanstack_react-form.js?v=473e5c45:1349:22
at Store.setState (@tanstack_react-form.js?v=473e5c45:296:22)
at FormApi.setFieldMeta (@tanstack_react-form.js?v=473e5c45:1344:22)
at @tanstack_react-form.js?v=473e5c45:1133:20
at batch (@tanstack_react-form.js?v=473e5c45:255:5)
at FormApi.validateSync (@tanstack_react-form.js?v=473e5c45:1090:7)
at FieldApi.validate (@tanstack_react-form.js?v=473e5c45:2205:97)
at FormApi.validateField (@tanstack_react-form.js?v=473e5c45:1080:28)
Your minimal, reproducible example
https://stackblitz.com/edit/vitejs-vite-egzzxehs?file=src%2FApp.tsx
Steps to reproduce
- Make a change in the form to trigger onChange event (you must see validation error for both fields)
- Click on
clear allorclean one - See console logs
TanStack Form version
1.19.2
TypeScript version
5.8.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked StackBlitz reproduction using TanStack Form 1.19.2 and follow the stack trace through FormApi.validateField, validateSync, and setFieldMeta. Compare form-level onChange validation when clearing all fields versus one array item; done means deletion no longer throws an undefined errorMap.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100