CodeStix/typed-react-form

only one error is shown at a time when calling `validate`

Closed this issue · 1 comments

vemoo commented

See: https://codesandbox.io/s/charming-feistel-4ih65?file=/src/App.tsx
You have to click submit two times for both errors to appear.

I think the issue is that here

changed =
changed ||
this.setError(
key,
errors[key] as any,
notifyChild,
false, // Will call updateParentErrors by itself after all values have been copied, see 3 lines down
false // Will call fireAnyListener by itself after all values have been copied, see 3 lines down
);
if changed is true setError is not called.

I guess it's like this to avoid setting all errors when one field changes. One option I can think of is for it to behave differently if it's called from validate.

Yup, you are right, I totally overlooked that. Thanks!