You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My goal is to show / hide form fields dynamically based on the selected value of a select input. Unfortunately the form errors on submission after changing selection or adding a value to a field array. The same setup seems to work fine in react.
Issue 1: Cannot read properties of undefined (reading 'onChange')
On the field labeld Type select Stage 2
Submit the form (will trigger error boundary)
Open browser dev tools and go to console
The following error should be present:
FieldApi.ts:1353 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'onChange')
at validateFieldFn (FieldApi.ts:1353:30)
at FieldApi.ts:1370:9
at batch (scheduler.ts:143:8)
at FieldApi.validateSync (FieldApi.ts:1325:5)
at FieldApi.validate (FieldApi.ts:1569:33)
at FormApi.ts:1149:29
at async Promise.all (solidjstemplatesgyky…ontainer.io/index 3)
at async FormApi.validateAllFields (FormApi.ts:1161:30)
at async FormApi.handleSubmit (FormApi.ts:1572:11)
Issue 2: Cannot read properties of undefined (reading 'length')
Press the Add Item button to add an empty entry to the items array
Submit the form (will trigger error boundary)
Open browser dev tools and go to console
The following error should be present:
TypeError: Cannot read properties of undefined (reading 'length')
at App.tsx:167:48
at Object.fn (chunk-KUGUZH4E.js?v=798142b7:677:60)
at runComputation (chunk-6YKRBNQN.js?v=798142b7:769:22)
at updateComputation (chunk-6YKRBNQN.js?v=798142b7:748:3)
at runTop (chunk-6YKRBNQN.js?v=798142b7:863:7)
at runUserEffects (chunk-6YKRBNQN.js?v=798142b7:960:18)
at chunk-6YKRBNQN.js?v=798142b7:932:34
at runUpdates (chunk-6YKRBNQN.js?v=798142b7:880:17)
at completeUpdates (chunk-6YKRBNQN.js?v=798142b7:932:17)
at runUpdates (chunk-6YKRBNQN.js?v=798142b7:881:5)
The error is caused reading errors.length on a field array subfield (L166-169).
Noticed the following regarding the first issue with reading onChange.
When changing the field Type to Stage 2 the form is reset by calling form.reset() in listeners and at that point the field Ref is not present in formApi's fieldMeta.
Found two ways to get around this problem:
<form.Fieldname="type"listeners={{onChange: ({ value })=>{Promise.resolve().then(()=>{form.reset(form.state.values);});},}}>
or
<form.Fieldname="type"listeners={{onChange: ({ value })=>{form.validate("change");form.reset(form.state.values);},}}>
The text was updated successfully, but these errors were encountered:
Describe the bug
My goal is to show / hide form fields dynamically based on the selected value of a select input. Unfortunately the form errors on submission after changing selection or adding a value to a field array. The same setup seems to work fine in react.
Your minimal, reproducible example
https://stackblitz.com/edit/solidjs-templates-vgzdkdzx?file=app%2FApp.tsx
Steps to reproduce
Issue 1: Cannot read properties of undefined (reading 'onChange')
Type
selectStage 2
The following error should be present:
Issue 2: Cannot read properties of undefined (reading 'length')
Add Item
button to add an empty entry to the items arrayThe following error should be present:
The error is caused reading
errors.length
on a field array subfield (L166-169).Expected behavior
Expecting not to throw any errors and work like the react version.
https://stackblitz.com/edit/vitejs-vite-vw2h5p9s?file=src%2FApp.tsx
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
TanStack Form adapter
solid-form
TanStack Form version
v0.45.1
TypeScript version
No response
Additional context
Noticed the following regarding the first issue with reading
onChange
.When changing the field
Type
toStage 2
the form is reset by callingform.reset()
in listeners and at that point the fieldRef
is not present in formApi's fieldMeta.Found two ways to get around this problem:
or
The text was updated successfully, but these errors were encountered: