gerhat / material-ui-formik-components

Formik ready material ui components
MIT License
85 stars 13 forks source link

"Select" component doesn't handle onChange #9

Closed pmacom closed 4 years ago

pmacom commented 5 years ago

In /sr/Select/Select.jsx there is a missing 'name' prop on the Select field. This is giving a warning onChange and actually prevents the field from updating correctly. I'll provide a PR a little bit later that fixes it. I'm not sure if the same issue exists in the typescript file. I haven't looked. I'm not really a typescript person yet. I also noticed an issue related to the 'shrink' prop on the input label. It was acting funky, I believe I fixed that as well. Should I make a separate issue/PR for that issue?

gerhat commented 4 years ago

Can you confirm this issue still exists. If you override onChange the value will not pass to formik but you can get it with e.target.value.

<Field
  required
  name="gender"
  label="Gender"
  options={[
    { value: '', label: '-- No selection --' },
    { value: 'Male', label: 'Male' },
    { value: 'Female', label: 'Female' },
    { value: 'Other', label: 'Other' },
  ]}
  component={Select}
  onChange={(e) => {
    console.log(e.target.value)
  }}
/>