Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New choices of AutocompleteInput not updating when chaging its value #10176

Open
ronfogel opened this issue Aug 31, 2024 · 1 comment
Open

New choices of AutocompleteInput not updating when chaging its value #10176

ronfogel opened this issue Aug 31, 2024 · 1 comment

Comments

@ronfogel
Copy link

ronfogel commented Aug 31, 2024

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
@djhi
Copy link
Collaborator

djhi commented Sep 2, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants