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

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

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ const GridSkeletonLoadingOverlay = React.forwardRef<
}

if (hasScrollbarFiller) {
rowCells.push(<GridScrollbarFillerCell pinnedRight={pinnedColumns.right.length > 0} />);
rowCells.push(
<GridScrollbarFillerCell
key={`skeleton-scrollbar-filler-${i}`}
pinnedRight={pinnedColumns.right.length > 0}
/>,
);
}
}

Expand Down
14 changes: 11 additions & 3 deletions packages/x-data-grid/src/components/containers/GridRootStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,11 +690,19 @@ export const GridRootStyles = styled('div', {
borderTop: '1px solid var(--DataGrid-rowBorderColor)',
},

/* Hide grid rows and vertical scrollbar when skeleton overlay is visible */
/* Hide grid rows, row filler, 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
Contributor 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
Contributor 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! 🎉

[`& .${c.virtualScrollerContent}`]: {
// We use visibility hidden so that the virtual scroller content retains its height.
// Position fixed is used to remove the virtual scroller content from the flow.
// https://github.com/mui/mui-x/issues/14061
position: 'fixed',
visibility: 'hidden',
},
[`& .${c['scrollbar--vertical']}, & .${c.pinnedRows}, & .${c.virtualScroller} > .${c.filler}`]:
{
display: 'none',
},
},
};

Expand Down