File tree Expand file tree Collapse file tree 4 files changed +19
-11
lines changed Expand file tree Collapse file tree 4 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 1- const DEFAULT_STACK_BEHAVIOR = 'replace ' ;
1+ const DEFAULT_STACK_BEHAVIOR = 'switch ' ;
22const DEFAULT_ENABLE_DISMISS_ON_CLOSE = true ;
33
44export { DEFAULT_STACK_BEHAVIOR , DEFAULT_ENABLE_DISMISS_ON_CLOSE } ;
Original file line number Diff line number Diff line change @@ -21,10 +21,11 @@ export interface BottomSheetModalProps
2121
2222 /**
2323 * Defines the stack behavior when modal mount.
24- * - `push` it will mount the modal on top of current modal.
25- * - `replace` it will minimize the current modal then mount the modal.
26- * @type `push` | `replace`
27- * @default replace
24+ * - `push` it will mount the modal on top of the current one.
25+ * - `switch` it will minimize the current modal then mount the new one.
26+ * - `replace` it will dismiss the current modal then mount the new one.
27+ * @type `push` | `switch` | `replace`
28+ * @default switch
2829 */
2930 stackBehavior ?: BottomSheetModalStackBehavior ;
3031
Original file line number Diff line number Diff line change @@ -50,13 +50,19 @@ const BottomSheetModalProviderWrapper = ({
5050 * - it is not unmounting.
5151 * - stack behavior is 'replace'.
5252 */
53+
54+ /**
55+ * Handle switch or replace stack behaviors, if:
56+ * - a modal is currently presented.
57+ * - it is not unmounting
58+ */
5359 const currentMountedSheet = _sheetsQueue [ _sheetsQueue . length - 1 ] ;
54- if (
55- currentMountedSheet &&
56- ! currentMountedSheet . willUnmount &&
57- stackBehavior === MODAL_STACK_BEHAVIOR . replace
58- ) {
59- currentMountedSheet . ref ?. current ?. minimize ( ) ;
60+ if ( currentMountedSheet && ! currentMountedSheet . willUnmount ) {
61+ if ( stackBehavior === MODAL_STACK_BEHAVIOR . replace ) {
62+ currentMountedSheet . ref ?. current ?. dismiss ( ) ;
63+ } else if ( stackBehavior === MODAL_STACK_BEHAVIOR . switch ) {
64+ currentMountedSheet . ref ?. current ?. minimize ( ) ;
65+ }
6066 }
6167
6268 /**
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ const SCROLLABLE_DECELERATION_RATE_MAPPER = {
100100const MODAL_STACK_BEHAVIOR = {
101101 replace : 'replace' ,
102102 push : 'push' ,
103+ switch : 'switch' ,
103104} ;
104105
105106const KEYBOARD_BEHAVIOR = {
You can’t perform that action at this time.
0 commit comments