From f397a8bb503f53d44816d49a7b9d6efd585b9c28 Mon Sep 17 00:00:00 2001 From: Rajat Date: Fri, 13 Dec 2024 14:48:14 +0530 Subject: [PATCH] [DataGrid] Toggle menu on click in `GridActionsCell` (#15867) --- .../x-data-grid/src/components/cell/GridActionsCell.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/x-data-grid/src/components/cell/GridActionsCell.tsx b/packages/x-data-grid/src/components/cell/GridActionsCell.tsx index 39c20b5c639e2..dbe8571e6cbb5 100644 --- a/packages/x-data-grid/src/components/cell/GridActionsCell.tsx +++ b/packages/x-data-grid/src/components/cell/GridActionsCell.tsx @@ -121,6 +121,13 @@ function GridActionsCell(props: GridActionsCellProps) { const hideMenu = () => { setOpen(false); }; + const toggleMenu = () => { + if (open) { + hideMenu(); + } else { + showMenu(); + } + }; const handleTouchRippleRef = (index: string | number) => (instance: TouchRippleActions | null) => { @@ -213,7 +220,7 @@ function GridActionsCell(props: GridActionsCellProps) { aria-controls={open ? menuId : undefined} role="menuitem" size="small" - onClick={showMenu} + onClick={toggleMenu} touchRippleRef={handleTouchRippleRef(buttonId)} tabIndex={focusedButtonIndex === iconButtons.length ? tabIndex : -1} {...rootProps.slotProps?.baseIconButton}