diff --git a/src/components/ContextMenu/ContextMenu.tsx b/src/components/ContextMenu/ContextMenu.tsx index 18368fbb7..3fa923915 100644 --- a/src/components/ContextMenu/ContextMenu.tsx +++ b/src/components/ContextMenu/ContextMenu.tsx @@ -33,6 +33,10 @@ const ContextMenu = ({ children, on, autoClose }: Props) => { setActive(false); }; + const stopPropagation = (event: React.MouseEvent | React.TouchEvent) => { + event.stopPropagation(); + }; + const onContextMenu = (event: MouseEvent) => { event.preventDefault(); const { clientX, clientY } = event; @@ -41,22 +45,10 @@ const ContextMenu = ({ children, on, autoClose }: Props) => { setActive(true); }; - const onClickOutside = () => { - close(); - }; - const onClick = useCallback(() => { autoClose && close(); }, [autoClose]); - const onMouseDown = (event: React.MouseEvent) => { - event.stopPropagation(); - }; - - const onTouchStart = (event: React.TouchEvent) => { - event.stopPropagation(); - }; - useEffect(() => { on.forEach((ref) => ref.current && ref.current.addEventListener('contextmenu', onContextMenu)); return () => on.forEach((ref) => ref.current && ref.current.removeEventListener('contextmenu', onContextMenu)); @@ -65,15 +57,15 @@ const ContextMenu = ({ children, on, autoClose }: Props) => { return active && createPortal((