-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] Grouped column menu shows redundant Divider #7025
Comments
There's no way to remove the divider in this column menu. You can only hide all dividers from all column menus. To fix this issue we need to change the way that the column menu items related to basic features (sorting, filtering, hiding) are added. We used to always add them, no matter if the feature is disabled. Now, this needs to be changed to only add them if the feature is enabled. Then, when adding the menu items for advanced features (row grouping, aggregation, column pinning), we check if there's already some menu item before adding the divider. Something like: diff --git a/packages/grid/x-data-grid/src/components/menu/columnMenu/GridColumnMenu.tsx b/packages/grid/x-data-grid/src/components/menu/columnMenu/GridColumnMenu.tsx
index 3e33f4e14..fc73b8732 100644
--- a/packages/grid/x-data-grid/src/components/menu/columnMenu/GridColumnMenu.tsx
+++ b/packages/grid/x-data-grid/src/components/menu/columnMenu/GridColumnMenu.tsx
@@ -14,23 +14,29 @@ const GridColumnMenu = React.forwardRef<HTMLUListElement, GridColumnMenuProps>(
const apiRef = useGridApiContext();
const defaultButtons = [
- <SortGridMenuItems onClick={hideMenu} column={currentColumn!} />, // TODO update types to allow `onClick` and `column` to be optional
- <GridFilterMenuItem onClick={hideMenu} column={currentColumn!} />,
- <HideGridColMenuItem onClick={hideMenu} column={currentColumn!} />,
- <GridColumnsMenuItem onClick={hideMenu} column={currentColumn!} />,
+ currentColumn?.sortable && <SortGridMenuItems onClick={hideMenu} column={currentColumn!} />, // TODO update types to allow `onClick` and `column` to be optional
+ !rootProps.disableColumnFilter && currentColumn?.filterable && (
+ <GridFilterMenuItem onClick={hideMenu} column={currentColumn!} />
+ ),
+ currentColumn?.hideable && <HideGridColMenuItem onClick={hideMenu} column={currentColumn!} />,
+ !rootProps.disableColumnSelector && (
+ <GridColumnsMenuItem onClick={hideMenu} column={currentColumn!} />
+ ),
];
const preProcessedButtons = apiRef.current.unstable_applyPipeProcessors(
'columnMenu',
- defaultButtons,
+ defaultButtons.filter(Boolean),
currentColumn,
);
return (
<GridColumnMenuContainer ref={ref} {...props}>
- {preProcessedButtons.map((button: any, index: number) =>
- React.cloneElement(button, { key: index, onClick: hideMenu, column: currentColumn }),
- )}
+ {preProcessedButtons
+ .filter(Boolean)
+ .map((button: any, index: number) =>
+ React.cloneElement(button, { key: index, onClick: hideMenu, column: currentColumn }),
+ )}
</GridColumnMenuContainer>
);
}, #6619 is implementing a completely new column menu that hopefully will handle this edge case. cc @MBilalShafi |
Order ID 💳
54867
Duplicates
Latest version
The problem in depth 🔍
When all the possible options (except the one that allows ungrouping) are turned off for the grouped column then there is a divider is shown:
Is there any way to hide it?
Here is live example: https://codesandbox.io/s/immutable-cherry-51xoxo?file=/demo.tsx
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: