From 4cf0b227f8b4468db513dea4c9c44c5e0928d98f Mon Sep 17 00:00:00 2001 From: Kawtar Choubari Date: Mon, 8 Jun 2026 14:03:04 +0200 Subject: [PATCH] fix(modal): keep minimize/dismiss status when sheet settles at closed position onChange fired before onClose (animateToPositionCompleted schedules both), overwriting the MINIMIZING/DISMISSING intent with MINIMIZED. onClose then treated a switch minimize as a dismiss and unmounted the sheet, tearing down nested child modals. Preserve the intent and let onClose resolve the final status. Closes #2685 --- src/components/bottomSheetModal/BottomSheetModal.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/bottomSheetModal/BottomSheetModal.tsx b/src/components/bottomSheetModal/BottomSheetModal.tsx index 2954b3f4..b428ec27 100644 --- a/src/components/bottomSheetModal/BottomSheetModal.tsx +++ b/src/components/bottomSheetModal/BottomSheetModal.tsx @@ -432,8 +432,15 @@ function BottomSheetModalComponent( currentIndexRef.current = _index; nextIndexRef.current = null; - statusRef.current = - _index === -1 ? MODAL_STATUS.MINIMIZED : MODAL_STATUS.PRESENTED; + const currentStatusIsDismissingOrMinimizing = [ + MODAL_STATUS.DISMISSING, + MODAL_STATUS.MINIMIZING, + ].includes(statusRef.current); + + if (!(currentStatusIsDismissingOrMinimizing && _index === -1)) { + statusRef.current = + _index === -1 ? MODAL_STATUS.MINIMIZED : MODAL_STATUS.PRESENTED; + } if (_providedOnChange) { _providedOnChange(_index, _position, _type);