From 6995f0efbd09d4c924544dacfe772a4e04f7f7a1 Mon Sep 17 00:00:00 2001 From: Ankita Date: Wed, 16 Dec 2020 10:46:05 +0530 Subject: [PATCH] fix reselect empty in autocomplete --- packages/ra-ui-materialui/src/input/AutocompleteInput.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/ra-ui-materialui/src/input/AutocompleteInput.tsx b/packages/ra-ui-materialui/src/input/AutocompleteInput.tsx index da67916470d..2c77a3ebd2c 100644 --- a/packages/ra-ui-materialui/src/input/AutocompleteInput.tsx +++ b/packages/ra-ui-materialui/src/input/AutocompleteInput.tsx @@ -265,9 +265,13 @@ const AutocompleteInput: FunctionComponent = props => { const handleChange = useCallback( (item: any) => { + if (getChoiceValue(item) == null && filterValue) { + setFilterValue(''); + } + input.onChange(getChoiceValue(item)); }, - [getChoiceValue, input] + [filterValue, getChoiceValue, input] ); // This function ensures that the suggestion list stay aligned to the