diff --git a/.changeset/cyan-shoes-beg.md b/.changeset/cyan-shoes-beg.md new file mode 100644 index 0000000000..b937a98a03 --- /dev/null +++ b/.changeset/cyan-shoes-beg.md @@ -0,0 +1,5 @@ +--- +"@comet/admin": minor +--- + +Hide group title in `CrudMoreActionsMenu` when only one group is present diff --git a/packages/admin/admin/src/dataGrid/CrudMoreActionsMenu.tsx b/packages/admin/admin/src/dataGrid/CrudMoreActionsMenu.tsx index 4fc1a9e150..0656e0d07e 100644 --- a/packages/admin/admin/src/dataGrid/CrudMoreActionsMenu.tsx +++ b/packages/admin/admin/src/dataGrid/CrudMoreActionsMenu.tsx @@ -44,7 +44,7 @@ export interface CrudMoreActionsMenuProps } interface CrudMoreActionsGroupProps { - groupTitle: ReactNode; + groupTitle?: ReactNode; menuListProps?: MenuListProps; typographyProps?: ComponentProps; } @@ -52,9 +52,11 @@ interface CrudMoreActionsGroupProps { function CrudMoreActionsGroup({ groupTitle, children, menuListProps, typographyProps }: PropsWithChildren) { return ( <> - theme.palette.grey[500]} sx={{ padding: "20px 15px 0 15px" }} {...typographyProps}> - {groupTitle} - + {groupTitle && ( + theme.palette.grey[500]} sx={{ padding: "20px 15px 0 15px" }} {...typographyProps}> + {groupTitle} + + )} {children} ); @@ -116,11 +118,13 @@ export function CrudMoreActionsMenu({ slotProps, overallActions, selectiveAction const handleClick = (event: MouseEvent) => setAnchorEl(event.currentTarget); const handleClose = () => setAnchorEl(null); + const hasOverallActions = !!overallActions?.length; + const hasSelectiveActions = !!selectiveActions?.length; return ( <> } {...buttonProps} onClick={handleClick}> - + {!!selectionSize && } - {!!overallActions?.length && ( + {hasOverallActions && ( } + groupTitle={ + hasSelectiveActions ? ( + + ) : undefined + } {...groupProps} > {overallActions.map((item, index) => { @@ -165,11 +173,15 @@ export function CrudMoreActionsMenu({ slotProps, overallActions, selectiveAction )} - {!!overallActions?.length && !!selectiveActions?.length && } + {hasOverallActions && hasSelectiveActions && } - {!!selectiveActions?.length && ( + {hasSelectiveActions && ( } + groupTitle={ + hasOverallActions ? ( + + ) : undefined + } {...groupProps} > {selectiveActions.map((item, index) => {