Skip to content

Commit

Permalink
[DataGrid] Refactor: create base MenuList props (#16481)
Browse files Browse the repository at this point in the history
  • Loading branch information
romgrk authored Feb 7, 2025
1 parent 587f7c5 commit fc6cd07
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ function GridActionsCell(props: GridActionsCellProps) {
className={gridClasses.menuList}
onKeyDown={handleListKeyDown}
aria-labelledby={buttonId}
variant="menu"
autoFocusItem
>
{menuButtons.map((button, index) =>
Expand Down
6 changes: 5 additions & 1 deletion packages/x-data-grid/src/material/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const baseSlots: GridBaseSlots = {
baseCircularProgress: MUICircularProgress,
baseDivider: MUIDivider,
baseLinearProgress: MUILinearProgress,
baseMenuList: MUIMenuList,
baseMenuList: BaseMenuList,
baseMenuItem: BaseMenuItem,
baseTextField: BaseTextField,
baseFormControl: MUIFormControl,
Expand All @@ -120,6 +120,10 @@ const materialSlots: GridBaseSlots & GridIconSlotsComponent = {

export default materialSlots;

function BaseMenuList(props: GridSlotProps['baseMenuList']) {
return <MUIMenuList {...props} />;
}

function BaseMenuItem(props: GridSlotProps['baseMenuItem']) {
const { inert, iconStart, iconEnd, children, ...other } = props;
if (inert) {
Expand Down
10 changes: 10 additions & 0 deletions packages/x-data-grid/src/models/gridBaseSlots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ export type IconButtonProps = Omit<ButtonProps, 'startIcon'> & {

export type DividerProps = {};

export type MenuListProps = {
ref?: Ref<HTMLUListElement>;
id?: string;
className?: string;
children?: React.ReactNode;
autoFocus?: boolean;
autoFocusItem?: boolean;
onKeyDown?: React.KeyboardEventHandler;
};

export type MenuItemProps = {
autoFocus?: boolean;
children?: React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { ButtonProps as MUIButtonProps } from '@mui/material/Button';
import type { CheckboxProps } from '@mui/material/Checkbox';
import type { CircularProgressProps as MUICircularProgressProps } from '@mui/material/CircularProgress';
import type { LinearProgressProps as MUILinearProgressProps } from '@mui/material/LinearProgress';
import type { MenuListProps } from '@mui/material/MenuList';
import type { MenuItemProps as MUIMenuItemProps } from '@mui/material/MenuItem';
import type { FormControlProps } from '@mui/material/FormControl';
import type { SelectProps } from '@mui/material/Select';
Expand Down Expand Up @@ -41,6 +40,7 @@ import type {
DividerProps,
IconButtonProps,
LinearProgressProps,
MenuListProps,
MenuItemProps,
SkeletonProps,
TooltipProps,
Expand Down

0 comments on commit fc6cd07

Please sign in to comment.