-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Variable row height #3218
[DataGrid] Variable row height #3218
Conversation
…DataGrid-variable-row-height
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Ok ... I would really like a review of what has been done so far. The functionality is almost ready but I'm struggling with fixing the failing tests. I'm probably missing a key interaction because this is closely tight to the virtualization and is impacted by every functionality that changes the rows in a way (sorting, filtering, pagination, treeData, density, etc). If someone can spare a pair of eyes to check it I would really appreciate it. I skipped 2 tests (both are the same, related to the translation using the Theme) - for some reason it enters an infinite loop there. Another thing that I don't really get is how are the tests from |
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.
I didn't look into the functionality yet. However, I'm already using some parts in #3387.
I don't think we should treat variable row height as a feature, the column variable width is not too.
For the remaining tests that are failing only with yarn test:unit
, you can fix them by using disableVirtualization
. They fail because in jsdom rootRef.current!.clientHeight!
is 0. You can refer to the master/detail PR because the CI is green there and I'm reusing most part of your work here.
packages/grid/_modules_/grid/hooks/features/rowHeight/useGridRowHeight.ts
Outdated
Show resolved
Hide resolved
6aef23a
to
ca386fa
Compare
if (!dimensions) { | ||
return 0; | ||
} | ||
const renderContext = apiRef.current.unstable_getRenderContext(); |
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.
I'm not a huge fan of exposing virtualization internals upper in the DataGrid component tree.
But I don't have a good solution either.
If @m4theushw has a better idea.
Otherwise, I'm fine with merging as is and taking time later to improve.
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.
Actually the keyboard navigation won't work as expected if disableVirtualization=true
. With virtualization disabled, the last row index in the render context points to the last row in the entire row set. I'm waiting for #3667 to be merged to able to test if there're no regressions. In the worst scenario, I would keep the old behavior if getRowHeight
is not being used.
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.
I tried calculating it without the renderContext
-> the problem is that because of the variable row height you need to know the indexes of the first and last rows in the viewport to calculate the total number of visible rows. If anyone have any ideas I'm open to them.
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.
There's a regression here. Pressing Page Up is jumping directly to the column header while not on the first row yet. I don't mind if we ship this small bug only affecting those users using getRowHeight
, but keeping the old behavior for those who don't use it. I think the correct way would be to base on rowsMeta.positions
and the current scroll position.
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.
Updated!
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
I've resolved a conflict caused by merging #3667 |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
…ailH/material-ui-x into feature/DataGrid-variable-row-height
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.
Well done.
…e/DataGrid-variable-row-height
Merged. I'll update the PR description for the release. |
Although we merged, there's still room for improvement. There're 3 things we could do in the future:
|
I created an issue to keep track of those subjects |
A thought on the |
Fixes #438
Preview -> https://deploy-preview-3218--material-ui-x.netlify.app/components/data-grid/rows/#variable-row-height
CHANGELOG entry for the release
🚣 Introduce variable row height (#438) @DanailH
Allow for setting a row-specific height. Before all rows had the same height, now you can set the height on a per-row basis.
ToDo: