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