-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Update <Datagrid>
and <SimpleList>
empty message when a filter is active
#10184
Conversation
Co-authored-by: Gildas Garcia <1122076+djhi@users.noreply.github.com>
packages/ra-ui-materialui/src/list/SimpleList/SimpleList.spec.tsx
Outdated
Show resolved
Hide resolved
packages/ra-ui-materialui/src/list/SimpleList/SimpleList.spec.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Francois Zaninotto <francois@marmelab.com>
packages/ra-ui-materialui/src/list/SimpleList/SimpleList.spec.tsx
Outdated
Show resolved
Hide resolved
); | ||
expect(screen.queryByText('ra.navigation.no_results')).not.toBeNull(); | ||
}); | ||
|
||
it('should display a message when there is no result but filters applied', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this test in the FilterButton tests file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we test the <SimpleList>
logic here. I use the FilterButton
's story to be able to test it with writing a new component. Do you prefer I write a new component to render that test ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then, why the SimpleList and not the List? Should we do both? @fzaninotto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, the List?oResults is used by SimpleList
and Datagrid
, so in theory we should test both. Instead, I added a test for ListNoResults
itself.
|
||
export const ListNoResults = memo(() => { | ||
const translate = useTranslate(); | ||
const resource = useResourceContext(); | ||
const { setFilters } = useListController({ resource }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useListContext
, not useListController
!
I fixed the mistake in 199fbae
No result found
message to “No [data] found using the current filters. Clear filters
<Datagrid>
and <SimpleList>
empty message when a filter is active
## Problem Since #10184, published in 5.2.0, `<SimpleList>` and `<Datagrid>` throw an error when used in standalone mode (i.e., outside of a ListContext) with an empty `data`. ## Solution The problem comes from `ListNoResults`, which reads the `ListContext` to determine if there is an active filter. ## Solution Use the alternative `useListContextWithProps` instead of `useListContext`.
## Problem Since marmelab#10184, published in 5.2.0, `<SimpleList>` and `<Datagrid>` throw an error when used in standalone mode (i.e., outside of a ListContext) with an empty `data`. ## Solution The problem comes from `ListNoResults`, which reads the `ListContext` to determine if there is an active filter. ## Solution Use the alternative `useListContextWithProps` instead of `useListContext`.
Problem
When coming back to a list page with active filters and no results, the default message (“no results found”) is misleading when the active filters aren’t visible enough.
Solution
If the list is empty AND there is an active filter,
To Do
Additional Checks
master
for a bugfix, ornext
for a feature- [ ] The documentation is up to date