Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List empty property not working as expected: empty component is not displayed when list is empty #5637

Closed
visithouse42 opened this issue Dec 7, 2020 · 3 comments · Fixed by #5688

Comments

@visithouse42
Copy link

visithouse42 commented Dec 7, 2020

What you were expecting:
When the <List empty={}> component is empty, the list should display the empty component.

What happened instead:
The provided empty component is not displayed when the list is empty, Took me a while to figure it out, it's related to checking the hasCreate state

Steps to reproduce:
Simply pass a custom component <List empty={<CustomComponent />}> to an empty list that doesn't have hasCreate=true
Seem like it's a bug related to the assumption that hasCreate needs to be true to display the empty component. The empty component should be displayed for any empty Lists regardless of the hasCreate status. One of our resources doesn't allow creation but we would still like to display custom empty components

Related code:
Should be an easy fix: (remove hasCreate check)

    const shouldRenderEmptyPage =
        hasCreate &&
        loaded &&
        !loading &&
        total === 0 &&
        !Object.keys(filterValues).length;

Environment

  • React-admin version: 3.10.2
  • React version: 17.0.1

Thanks for a great framework guys!

@djhi
Copy link
Collaborator

djhi commented Dec 8, 2020

Thanks for the report! Would you like to fix it?

@nausif
Copy link

nausif commented Dec 8, 2020

Hey, @djhi I would like to fix this one

@nausif
Copy link

nausif commented Dec 8, 2020

PR Created: #5641

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants