-
-
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 autoHeight computation for custom headers and footers #597
[DataGrid] Fix autoHeight computation for custom headers and footers #597
Conversation
…header and/or footer
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 think that we could have pushed the solution deeper. This is a partial solution. Consider the following case: https://codesandbox.io/s/cool-thunder-olrqk?file=/demo.js.
From my perspective, the best solution would be to move the AutoSizer
to the grid zone.
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.
autoHeight={false}
doesn't seem impacted (I don't know why), so happy to call it good enough.
https://codesandbox.io/s/romantic-mestorf-zw1vg?file=/demo.js
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
I explored that solution as well. It can be done but it involves removing |
diff --git a/packages/grid/_modules_/grid/GridComponent.tsx b/packages/grid/_modules_/grid/GridComponent.tsx
index 5e88c334..cc4a6bd2 100644
--- a/packages/grid/_modules_/grid/GridComponent.tsx
+++ b/packages/grid/_modules_/grid/GridComponent.tsx
@@ -103,8 +103,6 @@ export const GridComponent = React.forwardRef<HTMLDivElement, GridComponentProps
);
return (
- <AutoSizer onResize={onResize}>
- {(size: any) => (
<GridRoot
ref={handleRef}
className={props.className}
@@ -152,6 +150,8 @@ export const GridComponent = React.forwardRef<HTMLDivElement, GridComponentProps
gridState.rows.totalRowCount === 0 &&
customComponents.noRowsComponent}
{props.loading && customComponents.loadingComponent}
+ <AutoSizer onResize={onResize}>
+ {(size: any) => (
<GridWindow ref={windowRef}>
<GridDataContainer
ref={gridRef}
@@ -168,6 +168,8 @@ export const GridComponent = React.forwardRef<HTMLDivElement, GridComponentProps
)}
</GridDataContainer>
</GridWindow>
+ )}
+ </AutoSizer>
</div>
{customComponents.footerComponent || (
<DefaultFooter
@@ -194,8 +196,6 @@ export const GridComponent = React.forwardRef<HTMLDivElement, GridComponentProps
</ApiContext.Provider>
</ErrorBoundary>
</GridRoot>
- )}
- </AutoSizer>
);
},
); But if it's too much work, we can call the current solution an approximation, it's fine. |
unfortunately, I can't move it that far down. If I do other components also need tweaking (tried doing it and the But that brings other problems. The current solution works. Let's keep it for now and see if people find more problems with this we can spend a bit more time to rework the 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.
For point 1. #597 (comment), so we don't forget about it.
@DanailH Agree for 2. it would require a stronger refactorization. We can wait for developers complaining about the limitation before spending more time. This is the most pragmatic approach, I think. |
Updated the PR - we still need that prop as it is the default header height (not the columns header). |
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.
@dtassone What do you think about we rename headerHeight
to columnHeaderHeight
? Should we open a new issue about it? Right now, it could be confused with the height of the header component. Only the description clears the confusion:
Set the height in pixel of the column headers in the grid.
…TotalHeight" method
@dtassone can I merge this ? |
For the |
@dtassone I wonder if we can't even drop this |
Fixes #502
This PR aims to fix an issue that occurs when the autoHeight prop is set and a custom header and/or footer is provided. The bug is that the height of the grid, in that case, is not calculated correctly. That results in the last rows being hidden.