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

[data grid] Minimal overlay height with flex parent container (with dynamically height) #15516

Open
serrg opened this issue Nov 20, 2024 · 8 comments
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Rendering layout Related to the data grid Rendering engine status: waiting for author Issue with insufficient information support: pro standard Support request from a Pro standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@serrg
Copy link

serrg commented Nov 20, 2024

Steps to reproduce

Steps:

  1. Open this link to live example: https://stackblitz.com/edit/react-scjzzs?file=Demo.tsx

Current behavior

With using flex parent container without any minimum height, the overlay does not appear:

Screenshot 2024-11-20 at 14 13 13

The issue occurs both in v6 and v7 versions

Expected behavior

The overlay should always have a minimum height set in flex parent container (regardless the height):

Screenshot 2024-11-20 at 14 14 03

A possible workaround is to set a min-height: 104px on .MuiDataGrid-overlayWrapper. However, this change will also impact other overlays, such as the loading indicator.

Context

The data grid is mounted inside a flex parent container without a maximum height. It should adapt its size dynamically, taking up the entire viewport when needed and hugging the grid's contents otherwise:

Recording:
https://github.com/user-attachments/assets/71476685-48a1-4d65-ad95-8b2eb8744f9b

Your environment

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

Search keywords: data grid, auto height, parent container
Order ID: 82039

@serrg serrg added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 20, 2024
@github-actions github-actions bot added component: data grid This is the name of the generic UI component, not the React module! support: pro standard Support request from a Pro standard plan user. https://mui.com/legal/technical-support-sla/ labels Nov 20, 2024
@michelengelen
Copy link
Member

You can use the --DataGrid-overlayHeight variable for this.

@michelengelen michelengelen added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 21, 2024
@michelengelen michelengelen changed the title [DataGrid] Minimal overlay height with flex parent container (with dynamically height) [data grid] Minimal overlay height with flex parent container (with dynamically height) Nov 21, 2024
@michelengelen michelengelen added the feature: Rendering layout Related to the data grid Rendering engine label Nov 21, 2024
@serrg
Copy link
Author

serrg commented Nov 21, 2024

You can use the --DataGrid-overlayHeight variable for this.

@michelengelen Thanks for you answer but looks like setting '--DataGrid-overlayHeight': '300px' doesn't work in my case: https://stackblitz.com/edit/react-scjzzs?file=Demo.tsx

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 21, 2024
@michelengelen
Copy link
Member

That's weird, because the exact same thing works on my local machine. Might be a limitation of stackblitz 🤷🏼

Also you should follow the official approach to make the data grid adjust its height dynamically: flex parent container

@michelengelen michelengelen added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 21, 2024
@serrg
Copy link
Author

serrg commented Nov 21, 2024

That's weird, because the exact same thing works on my local machine. Might be a limitation of stackblitz 🤷🏼

I am just not sure how it can be affected by stackblitz 🤔 You can just open https://react-scjzzs.stackblitz.io/ directly and see that overlay has no default height

Also you should follow the official approach to make the data grid adjust its height dynamically: flex parent container

The above example strictly follows to the official approach, it is using the flex parent container

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 21, 2024
@serrg
Copy link
Author

serrg commented Nov 21, 2024

Applying --DataGrid-overlayHeight is not working because the parent container (MuiDataGrid-overlayWrapper in that case) has height set to 0

Screenshot 2024-11-21 at 23 02 48

@michelengelen
Copy link
Member

It has to do something with stackblitz, as the exact same code works locally and on codesandbox: DEMO

Thats not unusual though. We do some magic behind the scenes grabbing the variable from CSS and applying it in a function directly to the wrapper.

@michelengelen michelengelen added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 22, 2024
@serrg
Copy link
Author

serrg commented Nov 22, 2024

Thank you for setting up the sandbox, but it seems the code isn’t an exact match. You’re using the latest version of @mui/x-data-grid (7.22.3), whereas I’m working with version 7.22.2. Interestingly, it does work on 7.22.3 but not on 7.22.2 😅

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 22, 2024
@michelengelen
Copy link
Member

ah, my bad ... we fixed that recently and I did not check the version: #15535 🤔

@michelengelen michelengelen added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 22, 2024
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! feature: Rendering layout Related to the data grid Rendering engine status: waiting for author Issue with insufficient information support: pro standard Support request from a Pro standard plan user. https://mui.com/legal/technical-support-sla/
Projects
None yet
Development

No branches or pull requests

2 participants