Skip to content

Make ReferenceManyField compatible with filters #8642

Closed

Description

Is your feature request related to a problem? Please describe.

Today there is not guidance and support for filters within a ReferenceManyField. I am having difficulties trying to integrate react-admin filter system within a ReferenceManyField component.

Describe the solution you'd like

Digging into the source code of the List component, it looks like the react-admin way to setup filters in ReferenceManyField would be to write something like:

<ReferenceManyField
  reference="comments"
  target="postId"
  pagination={<Pagination />}
>
  <ListToolbar
    filters={commentFilters}
    actions={
      <TopToolbar>
        <FilterButton />
      </TopToolbar>
    }
  />
  <Datagrid bulkActionButtons={false}>
  ...
  </Datagrid>
</ReferenceManyField>

But this generates infinite loop when writing within a filter input (probably due to the fact that reference many field context is not exactly similar to the list context, especially in terms of URL sync settings).

Note 1: Today, ReferenceManyField pagination state is not storable in the URL and this feature request might be related to this subject: could a solution be to be able to specify a "urlKey" props to the ReferenceManyField component so that all the state of this field can be stored in URL without conflicting with possible other components?

Note 2: I am not quite sure to understand why react-admin needs to implement a useReferenceManyFieldController: why ReferenceManyField component can't directly use a useListController hook instead?

Activity

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

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions