-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[DataGrid] Fix blank space when using dynamic row height with pagination #5315
Conversation
These are the results for the performance tests:
|
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #5312 (comment)
let allRowsMeasured = lastMeasuredIndex === Infinity; | ||
if (currentPage.range?.lastRowIndex && !allRowsMeasured) { | ||
// Check if all rows in this page are already measured | ||
allRowsMeasured = lastMeasuredIndex >= currentPage.range.lastRowIndex; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #5312 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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.