Formik: Touched state isn't correct when dealing with array values

Created on 26 Jul 2019  路  10Comments  路  Source: formium/formik

馃悰 Bug report

Current Behavior

I have a multi-select field in Formik, which needs to be an array.
The touched state of this fields results in an empty array instead of true.

EDIT: This happens when submitting.

Expected behavior

The touched state of the array field should be a boolean.

Suggested solution(s)

Additional context

I have found this related issue https://github.com/jaredpalmer/formik/issues/793#issuecomment-492523947, but it is closed for inactivity, and the workaround suggested is not applicable for us.

Your environment

| Software | Version(s) |
| ---------------- | ---------- |
| Formik | 1.5.8 |
| React | 16.8.6 |
| TypeScript | not used |
| Browser | Chrome 75 |
| npm/Yarn | yarn 1.16.0 |
| Operating System | Windows 10 |

Bug

Most helpful comment

All 10 comments

Hi,

Can you reproduce the error in a codesanbox please ?

I have the same issue here. I have some array values in my form. They represent the choices taken by the user in a multi-selection field. I handle them as traditional values.

const initialValues = {
  normalValue: '',
  nullableValue: null,
  choices: ['defaultChoice'], // < this one is a multi-select `value`
};

The relative touched flag is an empty array instead the expected true boolean when I touch the value.

Handling arrays values is an intended Formik usage? Is this a bug of the touched logic or I'm missing something crucial?

Is there anything new about this?

Is this dead?

I'm getting the same error and I think this PR fixes #1134

How's the state on this? I have the same issue.

I'm experiencing the same problem. I can't figure out why... and it's only on submitting the form.

Confirmed issue in latest as well. It only occurs when submitting the form, normal handleBlur works perfectly.

repro

I think it's related to this issue here - https://github.com/jaredpalmer/formik/issues/1942
Not sure if it will be solved at all.

Was this page helpful?
0 / 5 - 0 ratings