form icon indicating copy to clipboard operation
form copied to clipboard

Form-level validation with onChange and arrays throws an undefined errorMap

Open stefan-huck opened this issue 4 months ago • 2 comments

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

  1. Make a change in the form to trigger onChange event (you must see validation error for both fields)
Image
  1. Click on clear all or clean one
  2. See console logs

TanStack Form version

1.19.2

TypeScript version

5.8.3

stefan-huck avatar Aug 20 '25 18:08 stefan-huck

I think related to: https://github.com/TanStack/form/pull/1706

kusiewicz avatar Aug 21 '25 08:08 kusiewicz

Hi! #1706 has been merged, and I've just tested your example with the latest version of form (1.23.8) and the bug seems to be gone, so this should probably be closed.

milan-codes avatar Nov 12 '25 10:11 milan-codes