Skip to content

Fix List shows empty page too often#10190

Merged
djhi merged 1 commit intomasterfrom
fix-empty
Sep 10, 2024
Merged

Fix List shows empty page too often#10190
djhi merged 1 commit intomasterfrom
fix-empty

Conversation

@fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Sep 10, 2024

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. 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).

image

Cause

This bug was introduced by #8945, which fixed a bug with partial pagination.

The condition for displaying the empty page is wrong, as it only counts the number of results in the current page (data.length) instead of the total number of results:

const shouldRenderEmptyPage =
!isPending &&
data?.length === 0 &&
!Object.keys(filterValues).length &&
empty !== false;

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
@djhi djhi merged commit 2575f8e into master Sep 10, 2024
@djhi djhi deleted the fix-empty branch September 10, 2024 12:12
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.

2 participants