-
-
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[data grid] Row with dynamic height doesnt shrink when resizing. #7817
Comments
When there're pinned columns, to keep the alignment between non-pinned columns, we set their height to the same height of the center columns. The problem is that once the center columns are resized, the height from the pinned columns is seen as the maximum height. We can solve this bug with the diff below: diff --git a/packages/grid/x-data-grid-pro/src/hooks/features/columnResize/useGridColumnResize.tsx b/packages/grid/x-data-grid-pro/src/hooks/features/columnResize/useGridColumnResize.tsx
index dcb67489b..cc3b0f3f6 100644
--- a/packages/grid/x-data-grid-pro/src/hooks/features/columnResize/useGridColumnResize.tsx
+++ b/packages/grid/x-data-grid-pro/src/hooks/features/columnResize/useGridColumnResize.tsx
@@ -189,6 +189,7 @@ export const useGridColumnResize = (
clearTimeout(stopResizeEventTimeout.current);
stopResizeEventTimeout.current = setTimeout(() => {
+ apiRef.current.resetRowHeights();
apiRef.current.publishEvent('columnResizeStop', null, nativeEvent);
if (colDefRef.current) {
apiRef.current.publishEvent( For now you can use the following workaround: <DataGridPro
onColumnWidthChange={() => {
apiRef.current.resetRowHeights();
}}
/> Updated CodeSandbox: https://codesandbox.io/s/stoic-star-162csg?file=/demo.tsx |
@m4theushw Thanks for the quick solution, that helps with the resizing. We have one more problem with density, we are setting density like this because of styling of our cells.
If I change from bigger density to smaller the height is not recalculated, is there a way I could do that on density change ? Thanks. |
I am having a similar issue with pinned columns and dynamic row height. However, I have the data grid inside of an auto-resizing panel, so I am unable to use the https://codesandbox.io/s/mui-x-issue-template-forked-vhbik7?file=/src/App.tsx |
@m4theushw resetRowHeights() has issues when the table pagination is turned on. It doesn't calculate the height correctly, causing a misalignment between the pinned columns and the rest of the table. |
Order ID 馃挸 (optional)
54652
Duplicates
Latest version
Steps to reproduce 馃暪
Link to live example: https://codesandbox.io/s/awesome-sky-5z49qw?file=/demo.tsx
Current behavior 馃槸
When you resize a column so the maximum height of the content in rows is smaller then row itself the row doesn't shrink in size.
Expected behavior 馃
Row height can decrease its height based on content and dynamic resizing.
Context 馃敠
It seems that for some reason
minHeight
isnt set to auto for a row even whengetRowHeight
prop return fnc with"auto"
. Its visible on the example that I posted, but in our project it started happening when we moved loading of data that is later transformed into dataGrid data from the component that host dataGrid and we are displaying that component conditionally after all the data from API are loaded.I tried to log whats happening in dataGrid and I found out that the height is set here to fixed value because
unstable_getRowInternalSizes
https://github.com/mui/mui-x/blob/next/packages/grid/x-data-grid/src/components/GridRow.tsx#L387 returns at first only{ detail, baseCenter }
but then (I assume after recalculation of rowHeights that is mentioned here #5782) it starts returning{ detail, baseCenter, baseLeft }
which disablesminHeight: "auto"
Your environment 馃寧
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: