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 incorrect panels position when using a toolbar #13474

Merged
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
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
Loading