Skip to content

ReferenceArrayInput with AutocompleteArrayInput clearing previously selected items on search #10272

@heywobu

Description

@heywobu

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

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:

  1. select tag 1
  2. search for 'Option'

Result

  1. The backend loses the first selected item, making the ReferenceArrayInput & the dropdown empty
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions