New choices of AutocompleteInput not updating when chaging its value
What you were expecting: When using custom choices, any changes to those choices should be reflected in the options.
What happened instead: It seems that the initial options are being displayed and filtered based on the input text.
Steps to reproduce: I followed the code from the AutocompleteInput documentation (for selecting a foreign key), which updates the choices after fetching new data.
Related code: https://marmelab.com/react-admin/AutocompleteInput.html#selecting-a-foreign-key
import React, { useState } from 'react';
import { AutocompleteInput, useGetList } from 'react-admin';
function LocodeInput(props: any) {
const [filter, setFilter] = useState({
q: '',
});
const { data, isPending } = useGetList('areas', { filter });
return (
<AutocompleteInput
source="locode"
label="Locode"
choices={data}
isPending={isPending}
optionText="id"
optionValue="id"
onInputChange={(e, value) => {
setFilter({
q: value,
});
}}
/>
);
}
export default LocodeInput;
Environment
- React-admin version: 5.1.3
- React version: 18.3.1
- Browser: Chrome
Thanks for reporting this. Please provide a sample application showing the issue by forking the following Stackblitz (https://stackblitz.com/github/marmelab/react-admin/tree/master/examples/simple).