Skip to content

Commit

Permalink
chore: add menuItemProps to dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
k0stik committed May 8, 2024
1 parent a66c18a commit 6bbf4e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion dist/mui/components/dropdown/Dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import { PopperPlacementType, PopperProps } from "@mui/material/Popper";
import React from "react";
import { DefaultDropdownButtonProps } from "./DefaultDropdownButton";
import { DropdownItemProps } from "./DropdownItem";
/**
* Add data-<something> html attributes
* @see https://github.com/microsoft/TypeScript/issues/28960#issuecomment-903519759
* */
interface HTMLAttributes extends React.HTMLAttributes<any> {
[dataAttribute: `data-${string}`]: any;
}
export interface DropdownAction {
id: DropdownItemProps["id"];
onClick: (action: DropdownAction, event: React.MouseEvent<HTMLLIElement>) => void;
Expand All @@ -19,7 +26,7 @@ export interface DropdownAction {
/**
* Pass any MUI MenuItem props here to customize appearance or html properties
*/
menuItemProps?: MenuItemProps;
menuItemProps?: MenuItemProps & HTMLAttributes;
}
export interface DropdownProps {
id?: string;
Expand All @@ -42,3 +49,4 @@ export interface DropdownProps {
* to dropdown menu items.
*/
export default function Dropdown({ id, actions, buttonContent, popperProps, children, disabled, paperPlacement, className, buttonProps, }: DropdownProps): React.JSX.Element;
export {};
10 changes: 9 additions & 1 deletion src/mui/components/dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ import React, { useCallback, useRef, useState } from "react";
import { DefaultDropdownButton, DefaultDropdownButtonProps } from "./DefaultDropdownButton";
import { DropdownItem, DropdownItemProps } from "./DropdownItem";

/**
* Add data-<something> html attributes
* @see https://github.com/microsoft/TypeScript/issues/28960#issuecomment-903519759
* */
interface HTMLAttributes extends React.HTMLAttributes<any> {
[dataAttribute: `data-${string}`]: any;
}

export interface DropdownAction {
id: DropdownItemProps["id"];
onClick: (action: DropdownAction, event: React.MouseEvent<HTMLLIElement>) => void;
Expand All @@ -32,7 +40,7 @@ export interface DropdownAction {
/**
* Pass any MUI MenuItem props here to customize appearance or html properties
*/
menuItemProps?: MenuItemProps;
menuItemProps?: MenuItemProps & HTMLAttributes;
}

export interface DropdownProps {
Expand Down

0 comments on commit 6bbf4e5

Please sign in to comment.