Skip to content

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

@visithouse42

Description

@visithouse42

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!

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