Skip to content
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

Empty List when partial paging and items in list less than pageSize #10240

Closed
AlexanderMityaev opened this issue Sep 25, 2024 · 2 comments · Fixed by #10248
Closed

Empty List when partial paging and items in list less than pageSize #10240

AlexanderMityaev opened this issue Sep 25, 2024 · 2 comments · Fixed by #10248
Assignees
Labels

Comments

@AlexanderMityaev
Copy link

What you were expecting:

Typical List with Datagrid work as described in documentation with partial pagination even if there are small amount of items in list (i.e. 1,2,3)

What happened instead:

After upgrade to 5.2.1 listview displays empty widget when amount of items in list is less or equal to current pageSize.
In that case getList result total field is null due to partial pagination, also hasPreviousPage and hasNextPage are both false, leading following code to show empty widget even when data is not empty.

Temporary workaround is to artificially set total: in dataprovider when hasPrevious === false && hasNext === false

Related code:

Code in react-admin/packages/ra-ui-materialui/src/list/ListView.tsx

const shouldRenderEmptyPage =
        // the list is not loading data for the first time
        !isPending &&
        // the API returned no data (using either normal or partial pagination)
        (total === 0 ||
            (total == null &&
                hasPreviousPage === false &&
                hasNextPage === false)) &&
        // the user didn't set any filters
        !Object.keys(filterValues).length &&
        // there is an empty page component
        empty !== false;

Environment

  • React-admin version: 5.2.1
@djhi
Copy link
Collaborator

djhi commented Sep 27, 2024

Thanks for reporting this. Please provide a sample application showing the issue by forking the following Stackblitz (https://stackblitz.com/github/marmelab/react-admin/tree/master/examples/simple).

@fzaninotto
Copy link
Member

Your description is good enough, and looking at the related code you included shows the bug. Thanks for the report, we'll look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants