From 43ab8e624056f8356090a5460b31e54f6d90ac9c Mon Sep 17 00:00:00 2001 From: Pavel Prichodko <14926950+prichodko@users.noreply.github.com> Date: Thu, 31 Mar 2022 15:13:44 +0200 Subject: [PATCH] feat(system): pass open state to children in ContextMenu --- .../status-react/src/system/context-menu/context-menu.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/status-react/src/system/context-menu/context-menu.tsx b/packages/status-react/src/system/context-menu/context-menu.tsx index e3e17d3a..c621ced1 100644 --- a/packages/status-react/src/system/context-menu/context-menu.tsx +++ b/packages/status-react/src/system/context-menu/context-menu.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { cloneElement, useState } from 'react' import * as Primitive from '@radix-ui/react-context-menu' @@ -18,12 +18,14 @@ interface TriggerProps extends ContextMenuTriggerProps { const ContextMenuTrigger = (props: TriggerProps) => { const { children, ...triggerProps } = props + const [open, setOpen] = useState(false) + const [trigger, menu] = children return ( - + - {trigger} + {cloneElement(trigger, { 'data-open': open })} {menu}