diff --git a/desktop/app/src/ui/components/ContextMenu.tsx b/desktop/app/src/ui/components/ContextMenu.tsx index 0e9d3f555..4c047f5b2 100644 --- a/desktop/app/src/ui/components/ContextMenu.tsx +++ b/desktop/app/src/ui/components/ContextMenu.tsx @@ -7,7 +7,14 @@ * @format */ -import {createElement, useContext, useCallback} from 'react'; +import { + createElement, + useContext, + useCallback, + forwardRef, + Ref, + ReactElement, +} from 'react'; import {ContextMenuContext} from './ContextMenuProvider'; import FlexColumn from './FlexColumn'; import {MenuItemConstructorOptions} from 'electron'; @@ -33,13 +40,10 @@ type Props = { * * Separators can be added by `{type: 'separator'}` */ -export default function ContextMenu({ - items, - buildItems, - component, - children, - ...otherProps -}: Props) { +export default forwardRef(function ContextMenu( + {items, buildItems, component, children, ...otherProps}: Props, + ref: Ref | null, +) { const contextMenuManager = useContext(ContextMenuContext); const onContextMenu = useCallback(() => { if (items != null) { @@ -51,9 +55,10 @@ export default function ContextMenu({ return createElement( component || FlexColumn, { + ref, onContextMenu, ...otherProps, }, children, ); -} +}) as (p: Props & {ref?: Ref}) => ReactElement;