From 2b7db1de586fcd6ae0f6f26a2f4c63c998dc5cb5 Mon Sep 17 00:00:00 2001 From: Venkateshwar Reddy Vurumalla Date: Wed, 18 Nov 2026 14:21:32 +0000 Subject: [PATCH] fix(react): keep overlay ref when dismiss is refused useOverlay cleared overlayRef/containerElRef unconditionally after awaiting overlay.dismiss(), so when canDismiss returned false the modal could no longer be dismissed: the next dismiss() call was a no-op because the ref was gone. Only clear the refs when dismiss() resolves to true, as proposed in #28964. Fixes #28964 --- packages/react/src/hooks/useOverlay.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/react/src/hooks/useOverlay.ts b/packages/react/src/hooks/useOverlay.ts index ec5460e2baa..4f4cedbdc42 100644 --- a/packages/react/src/hooks/useOverlay.ts +++ b/packages/react/src/hooks/useOverlay.ts @@ -84,9 +84,13 @@ export function useOverlay( }, []); const dismiss = useCallback(async (data?: any, role?: string) => { - overlayRef.current && (await overlayRef.current.dismiss(data, role)); - overlayRef.current = undefined; - containerElRef.current = undefined; + if (overlayRef.current) { + const didDismiss = await overlayRef.current.dismiss(data, role); + if (didDismiss) { + overlayRef.current = undefined; + containerElRef.current = undefined; + } + } }, []); return {