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] filter and columns poppers incorrectly positioned when using a toolbar #13442

Open
jcrang opened this issue Jun 11, 2024 · 1 comment · May be fixed by #13474
Open

[data grid] filter and columns poppers incorrectly positioned when using a toolbar #13442

jcrang opened this issue Jun 11, 2024 · 1 comment · May be fixed by #13474
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@jcrang
Copy link

jcrang commented Jun 11, 2024

Steps to reproduce

Link to live example: (required)
https://codesandbox.io/p/sandbox/relaxed-frost-vsxqk5?file=%2Fsrc%2FDemo.tsx

Steps:

  1. Click "Columns" or "Filters"

Note: this only occurs when using a toolbar. Poppers are correctly positioned when not using a toolbar.

Current behavior

Position of popper obscures headers

image

Expected behavior

Position of popper is below headers (as in MUI X 6):
https://codesandbox.io/p/sandbox/great-tree-hqkwng?file=%2Fsrc%2FDemo.tsx

image

Context

No response

Your environment

No response

Search keywords: datagrid toolbar popper

@jcrang jcrang added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jun 11, 2024
@michelengelen michelengelen changed the title [Data grid] filter and columns poppers incorrectly positioned when using a toolbar [data grid] filter and columns poppers incorrectly positioned when using a toolbar Jun 11, 2024
@michelengelen michelengelen added component: data grid This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 11, 2024
@michelengelen
Copy link
Member

Hey @jcrang
Thanks for raising this.
It is happening due to a change in the layout.

The fix would be a rather easy one, so I am opening it up as a good first issue.
To get the person started picking this up here is a diff with a fix:

diff --git a/packages/x-data-grid/src/components/containers/GridRoot.tsx b/packages/x-data-grid/src/components/containers/GridRoot.tsx
index d141c5a0f..62a777499 100644
--- a/packages/x-data-grid/src/components/containers/GridRoot.tsx
+++ b/packages/x-data-grid/src/components/containers/GridRoot.tsx
@@ -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;
@@ -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>
+    />
   );
 });

diff --git a/packages/x-data-grid/src/components/virtualization/GridTopContainer.tsx b/packages/x-data-grid/src/components/virtualization/GridTopContainer.tsx
index 88603b41c..fad36864b 100644
--- a/packages/x-data-grid/src/components/virtualization/GridTopContainer.tsx
+++ b/packages/x-data-grid/src/components/virtualization/GridTopContainer.tsx
@@ -4,6 +4,12 @@ import { styled } from '@mui/system';
 import { unstable_composeClasses as composeClasses } from '@mui/utils';
 import { gridClasses, getDataGridUtilityClass } from '../../constants/gridClasses';

+const GridPanelAnchor = styled('div')({
+  position: 'absolute',
+  top: `var(--DataGrid-headersTotalHeight)`,
+  left: 0,
+});
+
 const useUtilityClasses = () => {
   const slots = {
     root: ['topContainer'],
@@ -29,13 +35,17 @@ const Element = styled('div')({
 });

 export function GridTopContainer(props: React.HTMLAttributes<HTMLDivElement>) {
+  const { children, ...otherProps } = props;
   const classes = useUtilityClasses();

   return (
     <Element
-      {...props}
-      className={clsx(classes.root, props.className, gridClasses['container--top'])}
+      {...otherProps}
+      className={clsx(classes.root, otherProps.className, gridClasses['container--top'])}
       role="presentation"
-    />
+    >
+      {children}
+      <GridPanelAnchor role="presentation" data-id="gridPanelAnchor" />
+    </Element>
   );
 }

@michelengelen michelengelen added bug 🐛 Something doesn't work good first issue Great for first contributions. Enable to learn the contribution process. and removed status: waiting for author Issue with insufficient information labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants