question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Have multiple lists for same resource on the same page

See original GitHub issue

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

https://user-images.githubusercontent.com/80701113/158987824-c3505e2c-37cd-4c27-94fb-07c63cae83d9.mp4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
djhicommented, Jun 26, 2022

You can do that at the data provider level as well if you can’t change the API

1reaction
fzaninottocommented, Mar 21, 2022

To solve this I use the useUnselect and useUnselectAll hooks with the new store key to unselect rows when the user deletes them.

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.

it should at least be documented that the selection state will always be globally synced with the resource.

You’re right. Would you like to open a PR for that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding multiple list views to same resource - Admin-On-Rest
1) Look at the url of a normal list view page with filters set. That should give you the name of the parameters...
Read more >
Apply a common filter to multiple lists - TechNet - Microsoft
I have added all the lists as web parts on a single page. I am looking for a way to apply department filter...
Read more >
Multiple lists on one screen -- best approach?
If any of your pages goes more than two-deep, go with Solution B for all pages to be consistent within your app. If...
Read more >
<a>: The Anchor element - HTML: HyperText Markup Language
... (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, ...
Read more >
Getting started with IEEE referencing - Library Guides
If you want to refer to the same source twice or multiple times, ... opinion found within the same source at different page...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found