Skip to content

[DataGrid] Fix error logged during skeleton loading with nested data grid#14186

Merged
kenanyusuf merged 3 commits intomui:masterfrom
kenanyusuf:skeleton-loading-nested-grid-fix
Aug 14, 2024
Merged

[DataGrid] Fix error logged during skeleton loading with nested data grid#14186
kenanyusuf merged 3 commits intomui:masterfrom
kenanyusuf:skeleton-loading-nested-grid-fix

Conversation

@kenanyusuf
Copy link
Member

@kenanyusuf kenanyusuf commented Aug 13, 2024

When the skeleton loader is active, we hide the data grid scroller contents and vertical scrollbar with CSS. This works well for most cases, however, causes an issue when a data grid is nested within master details. A short summary of what happens:

  1. A master detail is expanded with a data grid rendered inside
  2. The main data grid loading prop gets set to true
  3. The nested data grid logs the following error:
    MUI X: useResizeContainer - The parent DOM element of the data grid has an empty height. Please make sure that this element has an intrinsic height. The grid displays with a height of 0px.

Fixes #14061

@kenanyusuf kenanyusuf requested a review from a team August 13, 2024 12:30
@kenanyusuf kenanyusuf added the scope: data grid Changes related to the data grid. label Aug 13, 2024
@mui-bot
Copy link

mui-bot commented Aug 13, 2024

Deploy preview: https://deploy-preview-14186--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 02ec8b5

@cherniavskii cherniavskii added the type: bug It doesn't behave as expected. label Aug 13, 2024
/* Hide grid rows and vertical scrollbar when skeleton overlay is visible */
[`& .${c['main--hasSkeletonLoadingOverlay']}`]: {
[`& .${c.virtualScrollerContent}, & .${c['scrollbar--vertical']}, & .${c.pinnedRows}`]: {
display: 'none',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried doing this instead:

visibility: 'hidden',
position: 'fixed',

It seems to work, but I'm unsure if this would work in every scenario.
What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem to work - I thought we tried this the other day 😅. I will do some more thorough testing to double check different scenarios.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the ideal combination here. The virtual scroller content retains it's height with visibility: hidden, fixing the issue with nested data grid. And position: fixed takes the element out of the flow. Will make the change, thanks @cherniavskii for taking a look.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! 🎉

@kenanyusuf kenanyusuf merged commit 1deed31 into mui:master Aug 14, 2024
@kenanyusuf kenanyusuf deleted the skeleton-loading-nested-grid-fix branch August 14, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: data grid Changes related to the data grid. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[data grid] Skeleton Loading Overlay Triggers Error with Master Detail Panel Containing Another DataGrid

3 participants