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

[data grid] Broken calculation and display with { value: -1, label: 'All', } pagesize option #11724

Closed
kno-raziel opened this issue Jan 17, 2024 · 5 comments
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Pagination Related to the data grid Pagination feature

Comments

@kno-raziel
Copy link

kno-raziel commented Jan 17, 2024

Steps to reproduce

Link to live example: (required)
Datagrid condesandbox
Steps:

  1. In the results per page select the "All" option
  2. Notice the text of the displayed rows is wrong, it says "100001–100000 of 100000" and is enabling the go to previous page button in the navigation.

Current behavior

text of the displayed rows is wrong, it says "100001–100000 of 100000" and is enabling the go to previous page button in the navigation

Screenshot 2024-01-17 at 11 54 30 AM

Error in console
image

Expected behavior

text of the displayed rows should say "1–100000 of 100000" and all the buttons in the pagination should be disabled

Documentation says

Customizes the options of the rows per page select field. If less than two options are available, no select field will be displayed. Use -1 for the value with a custom label to show all the rows.

It works perfectly if instead of -1 as the value for the ALL options we use the total number of items.

Like in this codesanbox

Screenshot 2024-01-17 at 12 12 24 PM

Context

We are trying to have an option in "Results per page" select to display all the rows.

Your environment

npx @mui/envinfo

System:
OS: macOS 14.2.1
Binaries:
Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
pnpm: 8.14.1 - ~/.nvm/versions/node/v18.18.0/bin/pnpm
Browsers:
Chrome: 120.0.6099.234
Edge: Not Found
Safari: 17.2.1
npmPackages:
@emotion/react: ^11.11.0 => 11.11.0
@emotion/styled: ^11.11.0 => 11.11.0
@mui/base: ^5.0.0-beta.4 => 5.0.0-beta.4
@mui/core-downloads-tracker: 5.14.11
@mui/icons-material: ^5.11.16 => 5.11.16
@mui/material: ^5.13.2 => 5.14.11
@mui/private-theming: 5.14.11
@mui/styled-engine: 5.14.11
@mui/system: 5.14.11
@mui/types: 7.2.4
@mui/utils: 5.14.11
@mui/x-data-grid: 6.18.6
@mui/x-data-grid-premium: ^6.18.6 => 6.18.6
@mui/x-data-grid-pro: 6.18.6
@mui/x-license-pro: 6.10.2
@types/react: ^18.2.24 => 18.2.24
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
styled-components: ^6.1.1 => 6.1.8
typescript: ~5.0.2 => 5.0.4

Chrome

Search keywords: datagrid pageSizeOptions

@kno-raziel kno-raziel added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 17, 2024
@kno-raziel
Copy link
Author

I believe the issue is the logic in this line, it doesnt take in to account the use of -1

https://github.com/mui/material-ui/blob/b6705ec218180021e2740d3b8244aca7f393a2ed/packages/mui-base/src/TablePagination/TablePagination.tsx#L229

@michelengelen michelengelen added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Pagination Related to the data grid Pagination feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 18, 2024
@michelengelen
Copy link
Member

Hey @kno-raziel ... thanks for raising this.
I can confirm that this is a bug. Even more so as the doc clearly states that this approach is the way to go. Thanks again! 🙇🏼

@michelengelen michelengelen changed the title Datagrid with pageSizeOptions=[10, 25, 50 ,{ value: -1, label: 'All', }] display wrong text [data grid] Broken calculation and display with { value: -1, label: 'All', } pagesize option Jan 18, 2024
@gitstart
Copy link
Contributor

gitstart commented Feb 9, 2024

@michelengelen @kno-raziel we would like to pick this up

@MBilalShafi
Copy link
Member

Fixed by #11958

Copy link

⚠️ This issue has been closed.
If you have a similar problem, please open a new issue and provide details about your specific problem.
If you can provide additional information related to this topic that could help future readers, please feel free to leave a comment.

How did we do @kno-raziel?
Your experience with our support team matters to us. If you have a moment, please share your thoughts through our brief survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Pagination Related to the data grid Pagination feature
Projects
Status: Done
Development

No branches or pull requests

4 participants