diff --git a/src/use-dropdown-menu.ts b/src/use-dropdown-menu.ts index 243986b..e2f7e3c 100644 --- a/src/use-dropdown-menu.ts +++ b/src/use-dropdown-menu.ts @@ -12,10 +12,11 @@ export interface ButtonProps // Create interface for item properties export interface ItemProps { - onKeyDown: (e: React.KeyboardEvent) => void; + onKeyDown: (e: React.KeyboardEvent) => void; tabIndex: number; role: string; - ref: React.RefObject; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ref: React.RefObject; } // A custom Hook that abstracts away the listeners/controls for dropdown menus @@ -43,8 +44,8 @@ export default function useDropdownMenu(null); - const itemRefs = useMemo[]>( - () => Array.from({ length: itemCount }, () => createRef()), + const itemRefs = useMemo[]>( + () => Array.from({ length: itemCount }, () => createRef()), [itemCount] ); @@ -171,7 +172,7 @@ export default function useDropdownMenu): void => { + const itemListener = (e: React.KeyboardEvent): void => { // Destructure the key property from the event object const { key } = e; @@ -189,7 +190,7 @@ export default function useDropdownMenu) => void; + onKeyDown: (e: React.KeyboardEvent) => void; tabIndex: -1; role: 'menuitem'; - ref: React.RefObject; + ref: React.RefObject; }; ... ]; @@ -45,4 +45,4 @@ This Hook returns an object of the following shape: - **ref:** A React ref applied to each menu item, used to manage focus. - **isOpen:** A boolean value indicating if the menu is open or closed. The developer should use this value to make the menu visible or not. - **setIsOpen:** A function useful for allowing the developer to programmatically open/close the menu. -- **moveFocus:** A function that moves the browser’s focus to the specified item index. \ No newline at end of file +- **moveFocus:** A function that moves the browser’s focus to the specified item index.