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

ReferenceInput -> AutocompleteInput in Filter very bad display

Open remi13131 opened this issue 9 years ago • 1 comments

Hi I have trouble with AutocompleteInput inside a ReferenceInput.

Right now EVERY records from the referenced entity are displayed, making impossible for the end user to properly choose the right record. If too many records are available, the list will even overflow from screen, making impossible to see all the available values.

In fact, when typing text inside the filter, the AutocompleteInput should IMO search through the records that are mapped to it (eg if I type test only db_name LIKE '%test%' in SQL syntax should be displayed in the list)

Example (sorry I had to hide part of db_name for privacy reasons but it is clear enough to understand): bug_referenceinput_autocompleteinput

remi13131 avatar Mar 15 '17 13:03 remi13131

Inside a <ReferenceField>, <AutocompleteInput> does issue a CRUD_GET_MATCHING action with the typed characters passed as filter (see the source for ReferenceInput). This action dispatches a GET_LIST REST query looking like:

GET_LIST posts {"pagination":{"page":1,"perPage":5},"sort":{"field":"title","order":"ASC"},"filter":{"q":"Lorem"}}

Where the q value is the typed string.

It's your responsibility to take the filter property into account in your restClient, so that it's transformed into something your REST API can understand.

fzaninotto avatar Mar 15 '17 17:03 fzaninotto