Skip to content

Commit 67e1e09

Browse files
magrinjgorhom
authored andcommitted
fix(bottom-sheet-modal): added container component prop to modal (#1309)(by @magrinj)
* fix: bottom sheet modal appear behind native views * feat: add bottomSheetWrapper prop to specify a custom wrapper component * fix: edit regardless of the comments
1 parent 630f87f commit 67e1e09

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

src/components/bottomSheetModal/BottomSheetModal.tsx

+18-15
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const BottomSheetModalComponent = forwardRef<
4545
snapPoints,
4646
enablePanDownToClose = true,
4747
animateOnMount = true,
48+
containerComponent: ContainerComponent = React.Fragment,
4849

4950
// callbacks
5051
onChange: _providedOnChange,
@@ -375,21 +376,23 @@ const BottomSheetModalComponent = forwardRef<
375376
handleOnUpdate={handlePortalRender}
376377
handleOnUnmount={handlePortalOnUnmount}
377378
>
378-
<BottomSheet
379-
{...bottomSheetProps}
380-
ref={bottomSheetRef}
381-
key={key}
382-
index={index}
383-
snapPoints={snapPoints}
384-
enablePanDownToClose={enablePanDownToClose}
385-
animateOnMount={animateOnMount}
386-
containerHeight={containerHeight}
387-
containerOffset={containerOffset}
388-
onChange={handleBottomSheetOnChange}
389-
onClose={handleBottomSheetOnClose}
390-
children={typeof Content === 'function' ? Content({ data }) : Content}
391-
$modal={true}
392-
/>
379+
<ContainerComponent>
380+
<BottomSheet
381+
{...bottomSheetProps}
382+
ref={bottomSheetRef}
383+
key={key}
384+
index={index}
385+
snapPoints={snapPoints}
386+
enablePanDownToClose={enablePanDownToClose}
387+
animateOnMount={animateOnMount}
388+
containerHeight={containerHeight}
389+
containerOffset={containerOffset}
390+
onChange={handleBottomSheetOnChange}
391+
onClose={handleBottomSheetOnClose}
392+
children={typeof Content === 'function' ? Content({ data }) : Content}
393+
$modal={true}
394+
/>
395+
</ContainerComponent>
393396
</Portal>
394397
) : null;
395398
});

src/components/bottomSheetModal/types.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ export interface BottomSheetModalProps
3535
*/
3636
enableDismissOnClose?: boolean;
3737

38+
/**
39+
* Add a custom container like FullWindowOverlay
40+
* allow to fix issue like https://github.com/gorhom/react-native-bottom-sheet/issues/832
41+
* @type React.ComponentType
42+
* @default undefined
43+
*/
44+
containerComponent?: React.ComponentType<React.PropsWithChildren<{}>>;
45+
3846
// callbacks
3947
/**
4048
* Callback when the modal dismissed.

0 commit comments

Comments
 (0)