From e5f664666881c899d3672de99c872e77609283e2 Mon Sep 17 00:00:00 2001 From: Ciaran Liedeman Date: Fri, 16 Oct 2020 21:16:21 +0200 Subject: [PATCH] fix: Fixed free solo multiple and added test case --- .../src/Autocomplete.tsx | 12 +++--- stories/lab/Autocomplete.story.tsx | 38 ++++++++++++++++--- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/packages/formik-material-ui-lab/src/Autocomplete.tsx b/packages/formik-material-ui-lab/src/Autocomplete.tsx index 2d798b07..f2ca4f2a 100644 --- a/packages/formik-material-ui-lab/src/Autocomplete.tsx +++ b/packages/formik-material-ui-lab/src/Autocomplete.tsx @@ -64,13 +64,11 @@ export function fieldToAutocomplete< function (event) { field.onBlur(event ?? field.name); }, - onChange: onChange - ? onChange - : !freeSolo - ? function (_event, value) { - setFieldValue(field.name, value); - } - : undefined, + onChange: + onChange ?? + function (_event, value) { + setFieldValue(field.name, value); + }, disabled: disabled ?? isSubmitting, loading: isSubmitting, ...fieldSubselection, diff --git a/stories/lab/Autocomplete.story.tsx b/stories/lab/Autocomplete.story.tsx index 4f363774..5bd7acdc 100644 --- a/stories/lab/Autocomplete.story.tsx +++ b/stories/lab/Autocomplete.story.tsx @@ -147,6 +147,7 @@ export default () => ( initialValues={{ single: top100Films[0], freeSolo: 'Godfather', + freeSoloMultiple: [], grouped: null, multiple: [top100Films[0]], }} @@ -188,8 +189,8 @@ export default () => ( renderInput={(params: AutocompleteRenderInputParams) => ( ( )} /> + + option.title)} + style={{ width: 300 }} + renderInput={(params: AutocompleteRenderInputParams) => ( + + )} + /> + ( renderInput={(params: AutocompleteRenderInputParams) => ( @@ -229,8 +255,8 @@ export default () => ( renderInput={(params: AutocompleteRenderInputParams) => (