Skip to content

Commit

Permalink
Fix grid overlay aligment with scroll for rtl (mui#15072)
Browse files Browse the repository at this point in the history
Co-authored-by: Rom Grk <[email protected]>
  • Loading branch information
kalyan90 and romgrk authored Nov 5, 2024
1 parent 5ac8393 commit 565de78
Showing 1 changed file with 13 additions and 3 deletions.
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 @@ -18,18 +18,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)', // TODO: take pinned rows into account
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

0 comments on commit 565de78

Please sign in to comment.