-
-
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
Fix <ListView>
should show custom empty component with partial pagination
#8945
Fix <ListView>
should show custom empty component with partial pagination
#8945
Conversation
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.
Nice catch, thanks!
Co-authored-by: Jean-Baptiste Kaiser <jbaptiste.kaiser@gmail.com>
Removed propTypes as you asked. I'm not sure though if I did not remove too many of them. Some of them are passed to the Also, I fixed the condition you proposed as it broke the test. Btw what's wrong with using optional chaining? |
Thanks for cleaning out the propTypes 🙂 Regarding the condition, it was not about the conditional chaining which is perfectly fine to use. With the original condition, when Hence I suggested Note that your latest version Can you fix it? |
In that case, your suggestion indeed makes sense. However, as I said, returning a custom component in case react-admin/packages/ra-ui-materialui/src/list/List.spec.tsx Lines 228 to 248 in 83aa214
The error component is rendered by the renderList function rather than renderEmpty , thus we intend shouldRenderEmptyPage to be false when data = undefined .
react-admin/packages/ra-ui-materialui/src/list/ListView.tsx Lines 54 to 79 in 83aa214
IMO this is the correct approach. The case when Also speaking of
|
Okay. I think you're right. Thanks for the detailed answer 🙂 Regarding the issue with |
<ListView>
should show custom empty component with partial pagination
Sure. I'll do that today evening. |
## Problem The default empty list page, which is an invite to create new elements, appears even when some elements already exist. Here is a repro that can be tested in the simple example: 1. For to the post list (in a large screen to show the datagrid version) 2. Select all rows using the top left checkbox 3. Hit the bulk delete button The empty page shows up, even though there are remaining posts (in the following page). ## Cause This bug was introduced by #8945, which fixed a bug with partial pagination. The condition for displaying the empty page is wrong: https://github.com/marmelab/react-admin/blob/e6129b2d1aded97f55bf40bf1d5602cc42a03113/packages/ra-ui-materialui/src/list/ListView.tsx#L60-L64
The default empty list page, which is an invite to create new elements, appears even when some elements already exist. Here is a repro that can be tested in the simple example: 1. Go to the post list (in a large screen to show the datagrid version) 2. Select all rows using the top left checkbox 3. Hit the bulk delete button The empty page shows up, even though there are remaining posts (in the following page). This bug was introduced by #8945, which fixed a bug with partial pagination. The condition for displaying the empty page is wrong: https://github.com/marmelab/react-admin/blob/e6129b2d1aded97f55bf40bf1d5602cc42a03113/packages/ra-ui-materialui/src/list/ListView.tsx#L60-L64
The logic that checks whether the custom empty component should be shown relies on the
total
value. Since react-admin supports partial pagination, it should handle that case too. This PR fixes that.