From b61ccfdab84f742f88b14ffdb02da480af33dd0b Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 1 Jul 2026 09:55:15 +0000 Subject: [PATCH] Keep nested dropdown dismissal local Radix can report a pointer down as outside the dialog while a portaled select or dropdown is open. When the pointer coordinates still fall within the dialog content bounds, keep the dialog open so the child popup can close without discarding form state. Signed-off-by: Cursor Agent --- packages/ui/src/Molecules/Dialog/Dialog.tsx | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/ui/src/Molecules/Dialog/Dialog.tsx b/packages/ui/src/Molecules/Dialog/Dialog.tsx index ec2f59cdf..0e6781ac0 100644 --- a/packages/ui/src/Molecules/Dialog/Dialog.tsx +++ b/packages/ui/src/Molecules/Dialog/Dialog.tsx @@ -69,6 +69,8 @@ type Props = { closable?: boolean; }; +type DialogContentPrimitiveProps = ComponentProps; + export const useDialogRef = (): DialogRef => { return useRef(null); }; @@ -85,6 +87,7 @@ export function Dialog({ }: Props) { const { overlay, content, header, title: titleClassname } = dialog(); const [open, setOpen] = useState(!!defaultOpen); + const contentRef = useRef(null); useEffect(() => { if (ref) { @@ -109,8 +112,24 @@ export function Dialog({ } }; + const preventDismissWhenPointerIsInsideContent: DialogContentPrimitiveProps["onPointerDownOutside"] = (event) => { + const originalEvent = event.detail.originalEvent; + const rect = contentRef.current?.getBoundingClientRect(); + if ( + rect + && originalEvent.clientX >= rect.left + && originalEvent.clientX <= rect.right + && originalEvent.clientY >= rect.top + && originalEvent.clientY <= rect.bottom + ) { + event.preventDefault(); + } + }; + const contentProps = closable - ? {} + ? { + onPointerDownOutside: preventDismissWhenPointerIsInsideContent, + } : { onEscapeKeyDown: (e: Event) => e.preventDefault(), onPointerDownOutside: (e: Event) => e.preventDefault(), @@ -123,8 +142,10 @@ export function Dialog({ {title