TanStack / form

🤖 Powerful and type-safe form state management for the web. TS/JS, React Form, Solid Form, Lit Form and Vue Form.
https://tanstack.com/form
MIT License
3.74k stars 338 forks source link

formAPI's onChange not called #489

Closed juliendelort closed 1 year ago

juliendelort commented 1 year ago

Describe the bug

formAPI's onChange doesn't seem to be called at all and it expects the same return type as fieldAPI's onChange. If we want to allow doing validation at the form level in onChange, we probably need it to return a mapping of errors per field (same with onBlur and async methods). Here is a repro of this.

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/determined-mayer-yn4qfc?file=%2Fsrc%2Findex.tsx%3A43%2C29

Steps to reproduce

  1. Open the repro link
  2. Make some changes to either field
  3. Check the console: nothing is logged despite console.log("****onChange called!"); inside onChange()

Expected behavior

"****onChange called!" should be logged in the console. Also, onChange returns "An error!" and I'm not sure what should happen with it. It could make more sense to return a mapping of errors per field.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Tanstack Form adapter

react-form

TanStack Form version

0.4.2

TypeScript version

No response

Additional context

No response

crutchcorn commented 1 year ago

This is a known bug, duplicate of:

466

This is the first thing I'm aiming to fix today