Skip to content
Source
Sign inSign up
TanStack/form

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

Openstefan-huck(GitHub profile, opens in a new tab) opened this issue 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

  1. 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.

  2. LeCarbonator(GitHub profile, opens in a new tab) added labelsv2: needs investigation

Sign in to join this conversation.