react-admin
react-admin copied to clipboard
In a List, also show the Empty component when no results and only a permanent filter
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
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
.
You're right. Problem solved by passing my <Empty />
element tot the empty
prop of the Datagrid
instead.
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.