Skip to content

Commit

Permalink
Fix condition of calling getSelectedValues (jaredpalmer#2881)
Browse files Browse the repository at this point in the history
Resolves - jaredpalmer#2657

Prevent calling getSelectedValues when the element has not options. (e.g. input type is email with multiple)
  • Loading branch information
Jinma Yamashita authored Dec 17, 2020
1 parent 7fdd514 commit e50040a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/brown-jokes-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'formik': patch
---

Prevent calling getSelectedValues when the element has not options
2 changes: 1 addition & 1 deletion packages/formik/src/Formik.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ export function useFormik<Values extends FormikValues = FormikValues>({
? ((parsed = parseFloat(value)), isNaN(parsed) ? '' : parsed)
: /checkbox/.test(type) // checkboxes
? getValueForCheckbox(getIn(state.values, field!), checked, value)
: !!multiple // <select multiple>
: options && multiple // <select multiple>
? getSelectedValues(options)
: value;
}
Expand Down

0 comments on commit e50040a

Please sign in to comment.