Skip to content

Conversation

@Madeorsk
Copy link
Contributor

@Madeorsk Madeorsk commented Sep 15, 2025

Problem

There's no empty property to ListBase and InfiniteListBase to show something when the list is empty. We currently need to use WithListContext to do so.

Solution

Add empty prop to ListBase and InfiniteListBase.

TODO

  • Add documentation
  • Add headless documentation

How To Test

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The PR includes unit tests (if not possible, describe why)
  • The PR includes one or several stories (if not possible, describe why)
  • The documentation is up to date

@Madeorsk Madeorsk added the WIP Work In Progress label Sep 15, 2025
@Madeorsk Madeorsk changed the title Add empty property to ListBase and InfiniteListBase. Add empty property to ListBase and InfiniteListBase Sep 15, 2025
@djhi djhi added RFR Ready For Review and removed WIP Work In Progress labels Nov 5, 2025
@slax57 slax57 requested review from Copilot and slax57 November 5, 2025 14:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an empty prop to ListBase and InfiniteListBase components, allowing developers to display a custom component when the list has no data and no active filters. This provides a better user experience by enabling custom empty states, such as inviting users to create their first record.

Key changes:

  • Added empty prop to ListBase and InfiniteListBase components and their TypeScript interfaces
  • Implemented logic to show the empty component when specific conditions are met (no errors, not loading, no data, no filters)
  • Excluded the empty prop from List and InfiniteList TypeScript interfaces since they delegate to ListView
  • Added documentation for the new empty prop with usage examples

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/ra-core/src/controller/list/ListBase.tsx Added empty prop to ListBase component with conditional rendering logic
packages/ra-core/src/controller/list/InfiniteListBase.tsx Added empty prop to InfiniteListBase component with conditional rendering logic
packages/ra-ui-materialui/src/list/List.tsx Excluded empty prop from List interface to avoid conflicts with ListView
packages/ra-ui-materialui/src/list/InfiniteList.tsx Excluded empty prop from InfiniteList interface to avoid conflicts with ListView
packages/ra-core/src/controller/list/ListBase.stories.tsx Added Empty story demonstrating the new empty prop functionality
packages/ra-core/src/controller/list/InfiniteListBase.stories.tsx Added Empty story demonstrating the new empty prop functionality
packages/ra-core/src/controller/list/ListBase.spec.tsx Added test for custom empty component rendering
packages/ra-core/src/controller/list/InfiniteListBase.spec.tsx Added test for custom empty component rendering
docs_headless/src/content/docs/ListBase.md Added documentation for the empty prop with usage examples
docs/ListBase.md Added reference link to the empty prop documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

);
```
## `empty`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a subtle difference between <ListBase empty> and <WithListContext empty> that could be worth mentioning IMO, for instance as a tip: <ListBase empty> renders only when there are no filters, whereas <WithListContext empty> renders as soon as the list is empty.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know if that's needed

@slax57 slax57 added this to the 5.13.0 milestone Nov 5, 2025
@slax57 slax57 merged commit cf71dae into next Nov 5, 2025
15 checks passed
@slax57 slax57 deleted the empty-list-base branch November 5, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Development

Successfully merging this pull request may close these issues.

4 participants