AutocompleteInput does not display choices
See original GitHub issueWhat you were expecting: I expected to enter a search string in the <AutocompleteInput/> and get autocomplete choices
What happened instead: The query returned a list of autocomplete options, but they were not displayed. Rather, they appear for a moment when I remove the focus from the field, then disappear.
Related code:
const TaskCreate = ({...props }) => {
const controllerProps = useCreateController(props);
return (
<CreateView
{...props}
{...controllerProps}
>
<SimpleForm >
<ReferenceInput source="maintainableItem" reference="Object" fullWidth >
<AutocompleteInput />
</ReferenceInput>
</SimpleForm>
</CreateView>
);
};
export default TaskCreate;
Other information:
that’s what the react-admin does right after the page loads:

response:

then i enter the search text:

response:

but nothing is displayed on the screen until I click on an empty spot:

after a moment, the autocomplete options disappear and the first 25 entries are displayed
Environment
- React-admin version: 3.1.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
AutocompleteInput suggestions are not working - Stack Overflow
It's simply not working. Typing in the AutocompleteInput will not filter the choices to select from for either consumers or providers.
Read more >The AutocompleteInput Component - React-admin - Marmelab
Tip: <AutocompleteInput> is a stateless component, so it only allows to filter the list of choices, not to extend it. If you need...
Read more >Autocomplete | Angular Material
Start by creating the autocomplete panel and the options displayed inside it. Each option should be defined by a mat-option tag.
Read more >Autocomplete API - Material UI - MUI
Name Type Default
options * array
renderInput * func
autoComplete bool false
Read more >Widgets and DOM elements — Bokeh 3.0.3 Documentation
Widgets are interactive control and display elements that can be added to Bokeh ... The AutocompleteInput widget is a general-purpose text input widget...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Empirically, I have identified the problem. It was hard to guess.
If the optionText property (default “name”) does not contain a search string ({filter: { q: “d2he”}}), then the options are not displayed !!!
The {filter: { q: “d2he”}} does not have to return objects with the “name” field that contains the search string. For example, my backend allows me to search by id, but I do not want to return the id to the AutocompleteInput option, I want to display the name, and I can not do this.
The AutocompleteInput does filtering on the client-side, and the ReferenceInput does filtering in the server side. Even though the AutocompleteInput does receive options, the ReferenceInput won’t display them if the
optionTextdoes not match the typed string.That’s what
matchSuggestionis for. It’s a function which check whether a choice matches a filter. It must return a boolean.It’s documented in the properties of the
AutocompleteInput: https://marmelab.com/react-admin/Inputs.html#autocompleteinput.