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

[DataGrid] Fix blank space when using dynamic row height with pagination #5315

Merged
merged 3 commits into from
Jul 12, 2022

Conversation

m4theushw
Copy link
Member

@m4theushw m4theushw commented Jun 24, 2022

1st bug preview: https://codesandbox.io/s/dynamicrowheightgrid-demo-mui-x-forked-6i5ct0?file=/demo.tsx

2nd bug preview: https://codesandbox.io/s/dynamicrowheightgrid-demo-mui-x-forked-uw5jw7?file=/demo.tsx

Fixes #5312

The problem here was that the last measured index was relative to the rows prop, not the current visible rows, as consequence it was using the exponential search instead of the binary search.

@m4theushw m4theushw added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Rendering layout Related to the data grid Rendering engine labels Jun 24, 2022
@mui-bot
Copy link

mui-bot commented Jun 24, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 269.1 485.6 411.7 384.44 95.438
Sort 100k rows ms 480.8 1,037.8 771 781.44 177.628
Select 100k rows ms 127.4 262.3 189.6 189.78 43.031
Deselect 100k rows ms 142.2 274.2 152.2 184.24 51.545

Generated by 🚫 dangerJS against 26eaa93

Comment on lines -120 to +123
const lastMeasuredIndex = Math.max(0, apiRef.current.unstable_getLastMeasuredRowIndex());
const allRowsMeasured = lastMeasuredIndex === Infinity;
const lastMeasuredIndexRelativeToAllRows = apiRef.current.unstable_getLastMeasuredRowIndex();
const lastMeasuredIndexRelativeToCurrentPage =
lastMeasuredIndexRelativeToAllRows - (currentPage.range?.firstRowIndex || 0);
const lastMeasuredIndex = Math.max(0, lastMeasuredIndexRelativeToCurrentPage);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +125 to +129
let allRowsMeasured = lastMeasuredIndex === Infinity;
if (currentPage.range?.lastRowIndex && !allRowsMeasured) {
// Check if all rows in this page are already measured
allRowsMeasured = lastMeasuredIndex >= currentPage.range.lastRowIndex;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@cherniavskii cherniavskii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@m4theushw m4theushw merged commit e63e8fa into mui:master Jul 12, 2022
@m4theushw m4theushw deleted the dynamic-row-height-with-pagination branch July 12, 2022 20:34
joserodolfofreitas pushed a commit to joserodolfofreitas/mui-x that referenced this pull request Jul 15, 2022
alexfauquette pushed a commit to alexfauquette/mui-x that referenced this pull request Aug 26, 2022
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: Rendering layout Related to the data grid Rendering engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Blank space when using pagination with dynamic row height
3 participants