Have multiple lists for same resource on the same page
See original GitHub issueIs your feature request related to a problem? Please describe.
We can display several lists on the same page by using the disablesyncwithlocation
List
prop. But if those lists use the same resource, their selection state is synced (while filters, pagination and data is not). Select items (for bulk actions) in one list, and the same selection gets applied to the other.
Describe the solution you’d like
It would be nice to be able to make selection local with the help of a prop similar to disablesyncwithlocation
. Ideally selection would have its own context like pagination and filters.
Describe alternatives you’ve considered
My current workaround is to not show the lists at the same time and hide one behind a dialog. When the dialog opens or closes, I call the useUnselectAll
hook to reset selection.
Additional context I tried to do this in both v3 and v4 and got the same problem.
From what I could see in the code this selection state is set in useListController
using the useRecordSelection
hook. In v3 selection is synced globally using the redux store, and in v4 it is also synced globally, but using the new useStore
hook.
Example
Here I am editing a museum. I want to display the list of people associated to the current museum and allow the user to add some from the list of all available people (Like ReferenceArrayInput
but with the power of the ListBase
component). So I have 2 lists in the same page with the resource Person
, so useRecordSelection
returns the same selection.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
You can do that at the data provider level as well if you can’t change the API
This means you’ve made changes to several components - not only the list, but also the DeleteButton and BulkDeleteButton. this isn’t a solution we can make generic, so this will stay in userland.
You’re right. Would you like to open a PR for that?