Skip to content
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

[DataGridPro] Incorrectly inheriting height from CSSGrid / Flexbox child since 6.2.0 #10520

Open
RobinVanCauter opened this issue Sep 30, 2023 · 4 comments · May be fixed by #10596
Open

[DataGridPro] Incorrectly inheriting height from CSSGrid / Flexbox child since 6.2.0 #10520

RobinVanCauter opened this issue Sep 30, 2023 · 4 comments · May be fixed by #10596
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module!

Comments

@RobinVanCauter
Copy link

RobinVanCauter commented Sep 30, 2023

Steps to reproduce

Link to live example: https://codesandbox.io/s/mui-x-issue-template-forked-463wrg?file=/src/App.tsx

Steps:

  1. Make sure viewport is small enough for the rows to overflow
  2. Try scrolling the table, it will scroll the entire page instead because DataGridPro is not overflowing

Current behavior

The DataGrid is not inheriting the height from it's parent, causing it to grow to whatever size is needed to fit all of the rows provided to the component and causing the entire page to scroll instead.

Expected behavior

The DataGrid should inherit the parent's height and show a scrollbar, like it used to in version < 6.2.0.

Context

We're trying to setup a layout using CSS grids, where the DataGrid takes up "whatever space is left".

After trying out a couple of versions we noticed the following:

  • it works as expected with any version BEFORE 6.2.0
  • all newer versions, including 6.2.0, experience the issue

Your environment

Browser: Chrome

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: DataGrid height flexbox css grid

@RobinVanCauter RobinVanCauter added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 30, 2023
@yaredtsy
Copy link
Contributor

yaredtsy commented Oct 2, 2023

hey @T-Grave

You can achieve this behavior by adding this.

[`& .MuiDataGrid-virtualScroller`]: {
   flex: "1 1 0px",
  overflow: "auto"
}

demo: https://codesandbox.io/s/mui-x-issue-template-forked-m5hlqs

@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label Oct 2, 2023
@DanailH
Copy link
Member

DanailH commented Oct 5, 2023

Thank you @yaredtsy the workaround seems to be working as expected. Either way, we need to see what caused the degradation in functionality.

@DanailH DanailH added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 5, 2023
@yaredtsy
Copy link
Contributor

yaredtsy commented Oct 5, 2023

hey @DanailH

This issue was caused by #8091. When GridAutoSizer was removed, the component responsible for handling resize based on flex was also removed with it. we can fix it like this.

--- a/packages/grid/x-data-grid/src/components/virtualization/GridVirtualScroller.tsx
+++ b/packages/grid/x-data-grid/src/components/virtualization/GridVirtualScroller.tsx
@@ -25,6 +25,8 @@ const VirtualScrollerRoot = styled('div', {
 })<{ ownerState: OwnerState }>({
   overflow: 'auto',
   height: '100%',
+  flex: '1 1 0',
   // See https://github.com/mui/mui-x/issues/4360
   position: 'relative',
   '@media print': {

demo : https://codesandbox.io/s/mui-x-issue-template-forked-rn9zfz?file=/src/App.tsx

@cherniavskii
Copy link
Member

Hi @T-Grave
I'm not 100% sure the DataGrid should inherit the parent's height as you expected.
I forked your sandbox and replaced the data grid with 2 divs instead to see how would regular HTML elements behave in this situation: https://codesandbox.io/s/mui-x-issue-template-forked-kxxvw3?file=/src/App.tsx
The behavior seems to be identical to the current behavior of the data grid.

I prefer to keep this behavior unless there's a strong argument to do otherwise.
What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants