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] Fix grid overlay aligment with scroll for RTL #15072

Merged
merged 2 commits into from
Nov 5, 2024
Merged
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
16 changes: 13 additions & 3 deletions packages/x-data-grid/src/components/base/GridOverlays.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,24 @@ interface GridOverlaysProps {
loadingOverlayVariant: GridLoadingOverlayVariant | null;
}

interface GridOverlayWrapperRootProps extends GridOverlaysProps {
right: number;
}

const GridOverlayWrapperRoot = styled('div', {
name: 'MuiDataGrid',
slot: 'OverlayWrapper',
shouldForwardProp: (prop) => prop !== 'overlayType' && prop !== 'loadingOverlayVariant',
shouldForwardProp: (prop) =>
prop !== 'overlayType' && prop !== 'loadingOverlayVariant' && prop !== 'right',
overridesResolver: (props, styles) => styles.overlayWrapper,
})<GridOverlaysProps>(({ overlayType, loadingOverlayVariant }) =>
})<GridOverlayWrapperRootProps>(({ overlayType, loadingOverlayVariant, right }) =>
// Skeleton overlay should flow with the scroll container and not be sticky
loadingOverlayVariant !== 'skeleton'
? {
position: 'sticky', // To stay in place while scrolling
top: 'var(--DataGrid-headersTotalHeight)',
left: 0,
right: `${right}px`,
width: 0, // To stay above the content instead of shifting it down
height: 0, // To stay above the content instead of shifting it down
zIndex:
Expand Down Expand Up @@ -80,7 +86,11 @@ function GridOverlayWrapper(props: React.PropsWithChildren<GridOverlaysProps>) {
const classes = useUtilityClasses({ ...props, classes: rootProps.classes });

return (
<GridOverlayWrapperRoot className={clsx(classes.root)} {...props}>
<GridOverlayWrapperRoot
className={clsx(classes.root)}
{...props}
right={dimensions.columnsTotalWidth - dimensions.viewportOuterSize.width}
>
<GridOverlayWrapperInner
className={clsx(classes.inner)}
style={{
Expand Down
Loading