Skip to content

Commit 731ac13

Browse files
committed
Merge branch 'gagik/headless-context-menu' of github.com:mongodb-js/compass into gagik/context-menu-compass-ui
2 parents 58df56a + a54c738 commit 731ac13

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/compass-context-menu/src/use-context-menu.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Context } from './context-menu-provider';
44
import { appendContextMenuContent } from './context-menu-content';
55
import type { ContextMenuItem } from './types';
66

7-
export type ContextMenuMethods = {
7+
export type ContextMenuMethods<T extends ContextMenuItem> = {
88
/**
99
* Close the context menu.
1010
*/
@@ -13,10 +13,12 @@ export type ContextMenuMethods = {
1313
* Register the menu items for the context menu.
1414
* @returns a callback ref to be passed onto the element responsible for triggering the menu.
1515
*/
16-
registerItems: (items: ContextMenuItem[]) => RefCallback<HTMLElement>;
16+
registerItems: (items: T[]) => RefCallback<HTMLElement>;
1717
};
1818

19-
export function useContextMenu(): ContextMenuMethods {
19+
export function useContextMenu<
20+
T extends ContextMenuItem = ContextMenuItem
21+
>(): ContextMenuMethods<T> {
2022
const context = useContext(Context);
2123
const previous = useRef<null | [HTMLElement, (event: MouseEvent) => void]>(
2224
null

0 commit comments

Comments
 (0)