Skip to content

Commit

Permalink
[DataGrid] Fix incorrect panels position when using a toolbar (#13474)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Cherniavskii <[email protected]>
  • Loading branch information
oukunan and cherniavskii committed Jul 10, 2024
1 parent 38def51 commit 863939d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
15 changes: 3 additions & 12 deletions packages/x-data-grid/src/components/containers/GridRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
unstable_capitalize as capitalize,
unstable_composeClasses as composeClasses,
} from '@mui/utils';
import { SxProps, styled } from '@mui/system';
import { SxProps } from '@mui/system';
import { Theme } from '@mui/material/styles';
import { GridRootStyles } from './GridRootStyles';
import { useGridSelector } from '../../hooks/utils/useGridSelector';
Expand Down Expand Up @@ -45,15 +45,9 @@ const useUtilityClasses = (ownerState: OwnerState) => {
return composeClasses(slots, getDataGridUtilityClass, classes);
};

const GridPanelAnchor = styled('div')({
position: 'absolute',
top: `var(--DataGrid-headersTotalHeight)`,
left: 0,
});

const GridRoot = React.forwardRef<HTMLDivElement, GridRootProps>(function GridRoot(props, ref) {
const rootProps = useGridRootProps();
const { children, className, ...other } = props;
const { className, ...other } = props;
const apiRef = useGridPrivateApiContext();
const density = useGridSelector(apiRef, gridDensitySelector);
const rootElementRef = apiRef.current.rootElementRef;
Expand Down Expand Up @@ -82,10 +76,7 @@ const GridRoot = React.forwardRef<HTMLDivElement, GridRootProps>(function GridRo
className={clsx(className, classes.root)}
ownerState={ownerState}
{...other}
>
<GridPanelAnchor role="presentation" data-id="gridPanelAnchor" />
{children}
</GridRootStyles>
/>
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { DataGridProcessedProps } from '../../models/props/DataGridProps';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import { useGridAriaAttributes } from '../../hooks/utils/useGridAriaAttributes';

const GridPanelAnchor = styled('div')({
position: 'absolute',
top: `var(--DataGrid-headersTotalHeight)`,
left: 0,
});

type OwnerState = DataGridProcessedProps;

const Element = styled('div', {
Expand Down Expand Up @@ -33,6 +39,7 @@ export const GridMainContainer = React.forwardRef<
tabIndex={-1}
{...ariaAttributes}
>
<GridPanelAnchor role="presentation" data-id="gridPanelAnchor" />
{props.children}
</Element>
);
Expand Down

0 comments on commit 863939d

Please sign in to comment.