Skip to content

Commit 0e385d6

Browse files
committed
fix(SubMenu): Adjust types
1 parent c015796 commit 0e385d6

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/components/SubMenu.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import { useState, useEffect, useCallback, useRef } from 'react';
1+
import { useState, useEffect, useRef, HTMLAttributes } from 'react';
22
import cx from 'clsx';
33

44
import { cloneChildren } from '../utils';
5-
import { MenuItemExternalProps, MenuItemProps } from './MenuItem';
5+
import { MenuItemExternalProps } from './MenuItem';
66

7-
export interface SubMenuProps extends Exclude<MenuItemProps, 'onClick'> {
7+
export interface SubMenuProps extends HTMLAttributes<HTMLDivElement> {
88
/**
99
* Label to display for the submenu.
1010
*/
1111
label: string;
12+
disabled?: boolean;
1213
}
1314

1415
const CLOSE_DELAY = 150;
@@ -29,11 +30,11 @@ const SubMenu = ({ label, children, className, disabled = false, ...rest }: SubM
2930
};
3031
}, []);
3132

32-
const clearTimer = useCallback(() => {
33+
const clearTimer = () => {
3334
if (timeoutRef.current) clearTimeout(timeoutRef.current);
34-
}, []);
35+
};
3536

36-
const calculatePosition = useCallback(() => {
37+
const calculatePosition = () => {
3738
if (subMenuRef.current && itemRef.current) {
3839
clearTimer();
3940
setActive(true);
@@ -51,20 +52,21 @@ const SubMenu = ({ label, children, className, disabled = false, ...rest }: SubM
5152
subMenuRef.current.classList.add(BOTTOM_CLASS);
5253
}
5354
}
54-
}, [subMenuRef, itemRef, clearTimer]);
55+
};
5556

56-
const onLeave = useCallback(() => {
57+
const onLeave = () => {
5758
clearTimer();
5859

5960
timeoutRef.current = setTimeout(() => {
6061
setActive(false);
6162
}, CLOSE_DELAY);
62-
}, [clearTimer]);
63+
};
6364

6465
const classNames = cx('react-context-menu__item', className, { 'react-context-menu__item--disabled': disabled });
6566

6667
return (
6768
<div
69+
{...rest}
6870
ref={itemRef}
6971
className={classNames}
7072
aria-haspopup="true"

0 commit comments

Comments
 (0)