Skip to content

Commit 1ecad69

Browse files
authored
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 ea03e78 commit 1ecad69

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

src/components/bottomSheetModal/BottomSheetModal.tsx

Lines changed: 20 additions & 17 deletions
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,23 +376,25 @@ 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={
391-
typeof Content === 'function' ? <Content data={data} /> : Content
392-
}
393-
$modal={true}
394-
/>
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={
393+
typeof Content === 'function' ? <Content data={data} /> : Content
394+
}
395+
$modal={true}
396+
/>
397+
</ContainerComponent>
395398
</Portal>
396399
) : null;
397400
});

src/components/bottomSheetModal/types.d.ts

Lines changed: 8 additions & 0 deletions
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)