Skip to content

Commit

Permalink
[DataGrid] Toggle menu on click in GridActionsCell (@k-rajat19) (#1…
Browse files Browse the repository at this point in the history
…5871)

Co-authored-by: Rajat <robertdoweny2301@gmail.com>
  • Loading branch information
arminmeh and k-rajat19 authored Dec 13, 2024
1 parent 3548ca8 commit c668591
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/x-data-grid/src/components/cell/GridActionsCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit c668591

Please sign in to comment.