1- import { ReactNode , useState , useCallback } from 'react' ;
1+ import { useState , useCallback , ButtonHTMLAttributes } from 'react' ;
22import cx from 'clsx' ;
33
4- export interface MenuItemProps {
5- /**
6- * Function to call when the item is clicked. Includes the click event.
7- */
8- onClick ?: ( event : React . MouseEvent < HTMLElement > ) => void ;
9- /**
10- * Whether the item is disabled.
11- *
12- * Default: `false`
13- */
14- disabled ?: boolean ;
15- className ?: string ;
16- children : ReactNode ;
17- }
4+ export interface MenuItemProps extends ButtonHTMLAttributes < HTMLButtonElement > { }
185
196export interface MenuItemExternalProps {
207 hide : ( ) => void ;
218}
229
2310interface MenuItemState {
2411 clicked : boolean ;
25- eventRef : React . MouseEvent < HTMLElement > | null ;
12+ eventRef : React . MouseEvent < HTMLButtonElement > | null ;
2613}
2714
2815const MenuItem = ( { children, onClick, className, disabled = false , ...rest } : MenuItemProps ) => {
2916 const [ state , setState ] = useState < MenuItemState > ( { clicked : false , eventRef : null } ) ;
3017
3118 const handleClick = useCallback (
32- ( event : React . MouseEvent < HTMLElement > ) => {
19+ ( event : React . MouseEvent < HTMLButtonElement > ) => {
3320 event . stopPropagation ( ) ;
3421
3522 if ( ! disabled && onClick ) {
@@ -57,7 +44,7 @@ const MenuItem = ({ children, onClick, className, disabled = false, ...rest }: M
5744 } ) ;
5845
5946 return (
60- < div
47+ < button
6148 onClick = { handleClick }
6249 onAnimationEnd = { handleAnimationEnd }
6350 className = { classNames }
@@ -66,7 +53,7 @@ const MenuItem = ({ children, onClick, className, disabled = false, ...rest }: M
6653 tabIndex = { - 1 }
6754 >
6855 { children }
69- </ div >
56+ </ button >
7057 ) ;
7158} ;
7259
0 commit comments