Skip to content

[TablePagination] Out of range warning when "count={-1}" #19865

@ilmiont

Description

@ilmiont
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

<TablePagination count={-1} page={0} rowsPerPage={10} />

The count={-1} should, per the documentation, indicate that the total count is unknown as we are (probably) using server-side pagination.

I therefore expect to be able to use the next/previous page toggles (excepting previous when on page 1), without the component attempting to enforce an acceptable page range (as it has no way of knowing what that is).

When the count={-1} prop is present, and the page prop changes to anything other than 0, the following warning appears in the console:

Warning: Failed prop type: Material-UI: the page prop of a TablePagination is out of range (0 to 0, but page is 1).

And despite purporting to be a warning, which I could somewhat tolerate, this is actually emitted as an error in the console.

Expected Behavior 🤔

When count={-1}, changing the page of the TablePagination should not emit this warning/error.

Steps to Reproduce 🕹

https://codesandbox.io/s/smoosh-cdn-ov0gg

Steps:

  1. Visit the Code Sandbox.
  2. Simply click the pagination next/previous page buttons and observe the console errors occuring.

Your Environment 🌎

Material UI v4.9.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGreat for first contributions. Enable to learn the contribution process.scope: tableChanges related to the table.type: bugIt doesn't behave as expected.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions