Commit 997d794 1 parent 5af3e80 commit 997d794 Copy full SHA for 997d794
File tree 4 files changed +19
-11
lines changed
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 ' ;
2
2
const DEFAULT_ENABLE_DISMISS_ON_CLOSE = true ;
3
3
4
4
export { 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
21
21
22
22
/**
23
23
* 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
28
29
*/
29
30
stackBehavior ?: BottomSheetModalStackBehavior ;
30
31
Original file line number Diff line number Diff line change @@ -50,13 +50,19 @@ const BottomSheetModalProviderWrapper = ({
50
50
* - it is not unmounting.
51
51
* - stack behavior is 'replace'.
52
52
*/
53
+
54
+ /**
55
+ * Handle switch or replace stack behaviors, if:
56
+ * - a modal is currently presented.
57
+ * - it is not unmounting
58
+ */
53
59
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
+ }
60
66
}
61
67
62
68
/**
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ const SCROLLABLE_DECELERATION_RATE_MAPPER = {
100
100
const MODAL_STACK_BEHAVIOR = {
101
101
replace : 'replace' ,
102
102
push : 'push' ,
103
+ switch : 'switch' ,
103
104
} ;
104
105
105
106
const KEYBOARD_BEHAVIOR = {
You can’t perform that action at this time.
0 commit comments