Skip to content

Commit c015796

Browse files
committed
fix(MenuItem): Adjust types
1 parent 784c6d4 commit c015796

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/components/MenuItem.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import cx from 'clsx';
33

44
export interface MenuItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {}
55

6-
export interface MenuItemExternalProps {
6+
export interface MenuItemExternalProps extends ButtonHTMLAttributes<HTMLButtonElement> {
77
hide: () => void;
88
}
99

@@ -15,17 +15,11 @@ interface MenuItemState {
1515
const MenuItem = ({ children, onClick, className, disabled = false, ...rest }: MenuItemProps) => {
1616
const [state, setState] = useState<MenuItemState>({ clicked: false, eventRef: null });
1717

18-
const handleClick = useCallback(
19-
(event: React.MouseEvent<HTMLButtonElement>) => {
20-
event.stopPropagation();
18+
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
19+
event.stopPropagation();
2120

22-
if (!disabled && onClick) {
23-
setState({ clicked: true, eventRef: event });
24-
}
25-
},
26-
// eslint-disable-next-line react-hooks/exhaustive-deps
27-
[onClick],
28-
);
21+
if (onClick) setState({ clicked: true, eventRef: event });
22+
};
2923

3024
const handleAnimationEnd = useCallback(() => {
3125
const { hide } = rest as MenuItemExternalProps;
@@ -45,11 +39,14 @@ const MenuItem = ({ children, onClick, className, disabled = false, ...rest }: M
4539

4640
return (
4741
<button
42+
{...rest}
4843
onClick={handleClick}
4944
onAnimationEnd={handleAnimationEnd}
5045
className={classNames}
5146
aria-disabled={disabled}
47+
disabled={disabled}
5248
role="menuitem"
49+
type="button"
5350
tabIndex={-1}
5451
>
5552
{children}

0 commit comments

Comments
 (0)