marmelab / react-admin

A frontend Framework for single-page applications on top of REST/GraphQL APIs, using TypeScript, React and Material Design
http://marmelab.com/react-admin
MIT License
24.89k stars 5.24k forks source link

In a List, also show the Empty component when no results and only a permanent filter #8320

Open christiaanwesterbeek opened 1 year ago

christiaanwesterbeek commented 1 year ago

Is your feature request related to a problem? Please describe.

The filter prop for List is considered a permanent filter. When an empty={<Empty />} prop is supplied to the List with such a permanent filter (and no results), the Empty component will not render. The documentation about it says (emphasis mine).

When there is no result, and there is no active filter, ..., react-admin displays ...

Describe the solution you'd like

Have you considered or will you consider showing the Empty page in this case? The permanent filter is not a user decision, so he should be invited to create a record within the fixed scope of the data.

Describe alternatives you've considered

Alternatively, I could add something underneath the Datagrid that fetches the list context and decide for it's own to show the Empty component...

Additional context

slax57 commented 1 year ago

I agree, this would be a welcome improvement.

Btw, I'm not 100% sure but I believe Datagrid has his own empty element, and there it is displayed from the moment there is no result, filters or not.

So basically we should do the same thing for all List child, and not only Datagrid.

christiaanwesterbeek commented 1 year ago

You're right. Problem solved by passing my <Empty /> element tot the empty prop of the Datagrid instead.

slax57 commented 1 year ago

Thanks @christiaanwesterbeek for this feedback. Still, I don't really see a good reason why the List's empty element would not be displayed when there are active filters. Hence I'll keep this feature request open, if anyone wants to have a look.