Closed rdougan closed 3 days ago
This is a CSS flexbox related problem, not a problem with the data grid. Top force the drawer to a specific width you can use flex: 1, minWidth: 240
.
Is this what you are looking for?
@michelengelen I've updated the codesandbox to remove width
and add minWidth
and flex
and the data grid does not follow the size of the container. If you remove the data grid, the container (red) resizes correctly.
I've gotten around it by wrapping the grid in a position: absolute
container:
<Box sx={{position: 'relative'}}>
<Box sx={{inset: 0, position: 'absolute'}}>
{...grid}
</Box>
</Box>
I do believe this is still a layout bug with DataGrid.
And another follow up...
The issue can be resolved by adding a minWidth: 0
to the parent container of the data grid.
I tend to disagree. It is not a layout bug of the data grid.
As mentioned before you are encountering a limitation of the flex-box property (and the css grid as well).
A flex item cannot be smaller than the size of its content along the main axis.
To be a bit clearer about this: The flex-child will always try to shrink to fit the size of the content, since min-width: auto
is set on it. That's why setting min-width: 0
solves this problem.
Very good answer about this on StackOverflow
Its great though that you could fix your problem. I will close this now! Thanks again for taking the time and opening an issue here!
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.
[!NOTE] @rdougan How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.
Steps to reproduce
Steps:
Current behavior
The drawer is not visible unless you make the window large enough for DataGrid full width + drawer. If you resize the window smaller, the
drawer
hides. If youExpected behavior
Drawer should take up full width of the container.
Context
I first noticed this as my app has a
Drawer
component withDataGrid
's sometimes appearing on screen with it. If I resize, I would like to show the drawer on the left, while showing the full widthDataGrid
.Your environment
OSX Chrome & Safari
Search keywords: datagrid width autoresize Order ID: 86320