react-admin
react-admin copied to clipboard
ReferenceArrayInput with AutocompleteArrayInput clearing previously selected items on search
When I have one or more items selected in the ReferenceArrayInput & I perform a new search in the AutocompleteArrayInput, the selected items are cleared out of the ReferenceArrayInput.
Frontend:
<ReferenceArrayInput
reference="tags" source="tags" name="name"
>
<AutocompleteArrayInput optionText="name" name="tags" />
</ReferenceArrayInput>
Backend response:
[
{
"id": "59655158-669b-453b-8290-3a2280ab5856",
"name": "Tag 1"
},
{
"id": "69655158-e69b-453b-8290-3a2280ab5856",
"name": "Option 2"
}
]
Steps to reproduce:
- select tag 1
- search for 'Option'
Result
- The backend loses the first selected item, making the ReferenceArrayInput & the dropdown empty
- the search result has no effect and the ReferenceArrayInput gets populated again with the selected items
My first guess is that when you're searching for the second item, the previously selected one isn't in the backend's response. The dropdown sees the new response of the backend, excluding the selected items (because it includes a new filter)
I'd assume that the selected items are cached in the ReferenceArrayInput and not impacted by a new search value.
For now I've made a workaround to include my selected values in my filterToQuery