From e72e6fec3bdde8b617e249cfd18181c439131ac8 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Wed, 1 Jul 2026 18:42:47 -0400 Subject: [PATCH] fix(modal): make dismiss idempotent when modal is not presented Calling dismiss() while the modal status is INITIAL (never presented, or already fully dismissed and reset) fell through the early-exit and left statusRef stuck at DISMISSING, after which every present() silently no-oped in handlePortalRender. Treat INITIAL as already-closed so dismiss() is safe to call from declarative wrappers that mirror an 'open' prop. Fixes #2669 --- src/components/bottomSheetModal/BottomSheetModal.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/bottomSheetModal/BottomSheetModal.tsx b/src/components/bottomSheetModal/BottomSheetModal.tsx index 2954b3f4..f87bde1d 100644 --- a/src/components/bottomSheetModal/BottomSheetModal.tsx +++ b/src/components/bottomSheetModal/BottomSheetModal.tsx @@ -273,13 +273,15 @@ function BottomSheetModalComponent( } /** - * if the modal position is already in a closed position, + * if the modal was never presented or is already in a closed position, * then we unmount the node and early exit. */ if ( - [MODAL_STATUS.CLOSED, MODAL_STATUS.MINIMIZED].includes( - statusRef.current - ) || + [ + MODAL_STATUS.INITIAL, + MODAL_STATUS.CLOSED, + MODAL_STATUS.MINIMIZED, + ].includes(statusRef.current) || (statusRef.current === MODAL_STATUS.DISMISSING && currentIndexRef.current === -1) ) {