-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] Rework column headers and virtual scroller positioning #7001
Conversation
These are the results for the performance tests:
|
e1c5e13
to
046655f
Compare
046655f
to
0ccc79a
Compare
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 checked the other regressions and it seems that the demo is wrong and this PR uncovered this problem. Before, with position: absolute
, it appeared to behave correctly because the dimensions of the absolute positioned element were not taken into account.
diff --git a/docs/data/data-grid/layout/FlexLayoutGrid.js b/docs/data/data-grid/layout/FlexLayoutGrid.js
index 807b56922..647ceed4a 100644
--- a/docs/data/data-grid/layout/FlexLayoutGrid.js
+++ b/docs/data/data-grid/layout/FlexLayoutGrid.js
@@ -11,7 +11,7 @@ export default function FlexLayoutGrid() {
return (
<div style={{ height: 400, width: '100%' }}>
- <div style={{ display: 'flex', height: '100%' }}>
+ <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
<div style={{ flexGrow: 1 }}>
<DataGrid {...data} />
</div>
diff --git a/docs/data/data-grid/row-height/ExpandableCells.js b/docs/data/data-grid/row-height/ExpandableCells.js
index 919ac9ff1..5df89012c 100644
--- a/docs/data/data-grid/row-height/ExpandableCells.js
+++ b/docs/data/data-grid/row-height/ExpandableCells.js
@@ -84,7 +84,7 @@ for (let i = 0; i < 10; i += 1) {
export default function ExpandableCells() {
return (
- <div style={{ height: 400, width: 800 }}>
+ <div style={{ height: 400, width: '100%' }}>
<DataGrid
rows={rows}
columns={columns}
The demo above tries to use width: 800px
but the test viewer has max-width: 500px
.
{...other} | ||
> | ||
{state.height === null && state.width === null ? null : children(childParams)} | ||
<div ref={handleRef} style={{ flex: 1, overflow: 'auto', ...style }} {...other}> |
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.
https://app.argos-ci.com/mui/mui-x/builds/6190/29684886 can be fixed with
<div ref={handleRef} style={{ flex: 1, overflow: 'auto', ...style }} {...other}> | |
<div ref={handleRef} style={{ flex: disableHeight ? 0 : '1 1 0px', overflow: 'auto', ...style }} {...other}> |
The reason for flex: 0
is because when auto height is enabled we don't want the content to shrink.
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.
Thanks for your help!
overflow: 'hidden', | ||
display: 'flex', | ||
alignItems: 'center', | ||
boxSizing: 'border-box', |
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.
This is a bugfix actually, you can see that in v5 the column header border is not visible when you have pinned rows:
https://codesandbox.io/s/strange-sea-6ul544?file=/demo.tsx
You cannot reproduce this in the same demo in the docs because in the docs we use CssBaseline which sets * { box-sizing: border-box }
.
I didn't want to extract this into a separate PR to save time.
I'll cherry-pick this change to master once this PR is merged.
Alright, I've finally managed to fix the regressions caused by the layout change 🎉 There are only 3 regressions left in https://app.argos-ci.com/mui/mui-x/builds/6762/31501643: All 3 are caused by height rounding that we did before. Now the virtual scroller uses the available space and sometimes it may have subpixel value: So I believe we should accept the screenshot changes since this is now the expected behavior 👍 |
<VirtualScrollerComponent | ||
ref={virtualScrollerRef} | ||
disableVirtualization={isVirtualizationDisabled} | ||
/> |
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 really like this change!
@@ -11,7 +11,7 @@ export default function FlexLayoutGrid() { | |||
|
|||
return ( | |||
<div style={{ height: 400, width: '100%' }}> | |||
<div style={{ display: 'flex', height: '100%' }}> | |||
<div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}> | |||
<div style={{ flexGrow: 1 }}> | |||
<DataGrid {...data} /> |
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 wonder what is the point of this demo.
There are 3 wrapper divs, 2 of which seem to be redundant since it's equivalent of
<div style={{ height: 400, width: '100%' }}>
<DataGrid {...data} />
</div>
What are we trying to cover in this section? https://mui.com/x/react-data-grid/layout/#flex-layout
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.
@m4theushw could you take a look at this one? It's off-topic, but it's not clear for me what's the intention of that demo
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 don't know why it has this structure. It was created already that way: https://github.com/mui/mui-x/pull/267/files#diff-b4e854d1aab47be29ed3d21847dbed928f8d36d3cafa0162b2ae35293fb9d6da
I suppose the outermost div (the one with height: 400px
) was added first to constrain the height so it doesn't extend the full page height. In a real scenario this div wouldn't be needed. Then, the intermediary div (the one with display: flex
) was added is to simulate how flex layout is used in real applications. I think the outermost and the intermediary divs can be merged, and height: 100%
-> height: 400px
.
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.
If I recall correctly, I used https://ag-grid.com/javascript-data-grid/grid-size/#inside-flexbox-container as inspiration for this demo. But in hindsight, it feels that developers learn nothing from https://next.mui.com/x/react-data-grid/layout/#flex-layout. It could be good to delete this h2 section. This would make more sense
but really? Do we need to teach developer CSS Grid/Flexbox?
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.
Thanks, @oliviertassinari
Few minor concerns I also had about the flex demo:
- Developers might think that a flex container is required for the grid to work (especially on a quick look at the docs, since it's the first demo on the page).
- Developers might copy the whole snippet with 2 nested divs, which is ... unnecessarily complicated 🤷🏻♂️
but really? Do we need to teach developer CSS Grid/Flexbox?
I think we can remove the whole section. The main requirement for the parent container is covered in the first few sentences anyway
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.
It sounds like this is fixed now 👍 https://stackblitz.com/edit/react-8ahs3n?file=src%2FApp.js
https://mui-org.slack.com/archives/C041SDSF32L/p1674915288809749
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
fd136a0
to
07b9cf3
Compare
Closes #602
TODO:
master
branch: [DataGridPro] Fix missing column headers border with top-pinned rows #7399Changelog
Breaking changes
headerHeight
prop was renamed tocolumnHeaderHeight