diff --git a/src/components/RadialMenu.jsx b/src/components/RadialMenu.jsx index 4cff975..fa411b3 100644 --- a/src/components/RadialMenu.jsx +++ b/src/components/RadialMenu.jsx @@ -44,24 +44,6 @@ export default function RadialMenu({ return () => window.removeEventListener('keydown', handleKey) }, [open, onDismiss]) - // Handle click outside - useEffect(() => { - if (!open) return - const handleClick = (e) => { - if (containerRef.current && !containerRef.current.contains(e.target)) { - onDismiss?.() - } - } - // Delay to avoid triggering on the same click that opened the menu - const timer = setTimeout(() => { - window.addEventListener('click', handleClick) - }, 50) - return () => { - clearTimeout(timer) - window.removeEventListener('click', handleClick) - } - }, [open, onDismiss]) - // Calculate which wedge the pointer is over const getWedgeAtPoint = useCallback((clientX, clientY) => { const dx = clientX - x @@ -109,6 +91,17 @@ export default function RadialMenu({ onDismiss?.() }, [getWedgeAtPoint, lat, lon, onDismiss]) + // Handle backdrop click (dismiss menu) + const handleBackdropClick = useCallback((e) => { + e.stopPropagation() + onDismiss?.() + }, [onDismiss]) + + // Prevent menu container clicks from reaching backdrop + const handleContainerClick = useCallback((e) => { + e.stopPropagation() + }, []) + // Generate wedge paths const generateWedgePath = (index) => { const startAngle = (index * wedgeAngle - 90) * (Math.PI / 180) @@ -144,126 +137,143 @@ export default function RadialMenu({ const clampedY = Math.max(padding, Math.min(window.innerHeight - padding, y)) const content = ( -