react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

AutocompleteInput not working inside SimpleFormIterator and ReferenceInput

Open zavadpe opened this issue 8 years ago • 3 comments

What you were expecting: AutoCompleteInput can be used for reference selection inside SimpleFormIterator and ReferenceInput.

What happened instead: AutoCompleteInput doesn't suggest relevant references at the top when user inputs matching text. For example user inputs "Sporting" (there's a place with a name Sporting Center) but this place is not suggested at the top. It seems that places are not filtered at all.

autocomplete_scrshot

Related code: Displaying items inside the list of references

<FormTab label="resources.tabs.list">
  <ArrayInput source="items">
    <SimpleFormIterator>
      <ReferenceInput label="resources.places" source="id" reference="places" >
        <AutocompleteInput optionText="title.en" />
      </ReferenceInput>
    </SimpleFormIterator>
  </ArrayInput>
</FormTab>

List model:

{
  ...
  items: [
    { id: <ID>}
  ]
}

Place model:

{
  id: <ID>,
  title: {
    en: <EN TITLE>
  }
}

Environment

  • React-admin version: 2.0.0-RC3
  • React version: 16.3.2
  • Browser: any

zavadpe avatar May 11 '18 14:05 zavadpe

Hi,

I am also encountering something similar to this issue, but I would say, that Autocomplete component doesn't work at all (ie the bug is not related to ReferenceInput or SimpleForm).

After some debug, it looks like Autocomplete.handleSuggestionsFetchRequested method is bugged and does not update the suggestion list. I'm working on a fix and will share it when ready.

The Material-ui autosuggest example helped me in discovering it.

Stoakes avatar Jun 10 '18 18:06 Stoakes

It's the API responsability to filter the items when using a ReferenceInput:

This component fetches the possible values in the reference resource (using the GET_LIST REST method).

Are you sure you return filtered items ?

djhi avatar Jun 11 '18 07:06 djhi

@djhi: You were right, after thorough debugging I found mismatch between my filtering API calls which I didn't notice before. Thanks for pointing this out! This issue can be closed.

zavadpe avatar Jun 18 '18 13:06 zavadpe