Closed fzaninotto closed 2 years ago
What you were expecting:
Emptying AutocompleteInput shows list of suggestions
What happened instead:
Emptying AutocompleteInput provokes an infinite rerender
Steps to reproduce:
Related code:
<ReferenceInput source="post_id" reference="posts" perPage={15} sort={{ field: 'title', order: 'ASC' }} > <AutocompleteInput create={<CreatePost />} matchSuggestion={( filterValue, suggestion ) => { const title = `${suggestion.title} - ${suggestion.id}`; return title.includes(filterValue); }} optionText={<OptionRenderer />} inputText={inputText} fullWidth /> </ReferenceInput>
Other information:
https://user-images.githubusercontent.com/99944/161535799-c1502f10-21ff-43eb-86c2-644c28408f9f.mov
Environment
This happens because of the value being set and then the filter being set ( debounced or not )
https://github.com/marmelab/react-admin/blob/6c76cca9494acee696463005e86fbfbcb83bb113/packages/ra-ui-materialui/src/input/AutocompleteInput.tsx#L352
You can reproduce this as well if you erase the input in any other way
What you were expecting:
Emptying AutocompleteInput shows list of suggestions
What happened instead:
Emptying AutocompleteInput provokes an infinite rerender
Steps to reproduce:
Related code:
Other information:
https://user-images.githubusercontent.com/99944/161535799-c1502f10-21ff-43eb-86c2-644c28408f9f.mov
Environment