react-native-bottom-sheet icon indicating copy to clipboard operation
react-native-bottom-sheet copied to clipboard

fix(bottom-sheet-modal): behind native modal view

Open magrinj opened this issue 2 years ago • 5 comments

Fix issue #832

Motivation

Using react-navigation or native Modal component with BottomSheetModal component will show them behind the native views. As suggested in react-native-portal library, we should wrap the content inside FullWindowOverlay to get the view above all the native views. https://github.com/gorhom/react-native-portal#react-native-screens-integration

magrinj avatar Sep 02 '22 09:09 magrinj

Would very much like to see this land as well!

bitcrumb avatar Sep 08 '22 20:09 bitcrumb

@magrinj thanks for submitting this PR, my concern is that the library will have react-native-screens as a required dependency, which may not be the case for all users

gorhom avatar Sep 09 '22 20:09 gorhom

@magrinj thanks for submitting this PR, my concern is that the library will have react-native-screens as a required dependency, which may not be the case for all users

Would it be an option to have an (optional) overlayComponent prop on BottomSheetModal, which you would render around the BottomSheet inside Portal? This way we can "inject" the necessary wrapper (being the FullWindowOverlay of react-native-screens)? I get that it maybe is a weird prop to have, since it only makes sense for this use-case. But I wanted to bring it up anyway. This issue prevents me from using this library in most of the projects we maintain, since they all use "native" navigation as much as possible, which always includes proper modals.

bitcrumb avatar Sep 12 '22 05:09 bitcrumb

I agree with @bitcrumb that this is an important feature. Native stack navigators is now the recommended way to go with React Navigation and all our projects use native modals which in turn makes using BottomSheetModal impossible. patch-package for rescue until this is merged or resolved somehow else

Shaninnik avatar Sep 12 '22 13:09 Shaninnik

@gorhom I understand that point, as suggested by @bitcrumb we can create a custom prop called wrapperComponent or containerComponent. We can also put all the hooks of the component BottomSheetModalComponent in a custom exported hook. So user can recreate this component from scratch, in the way they want it. Let me know your preference, I'll definitely update my PR !

magrinj avatar Sep 12 '22 13:09 magrinj

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Oct 13 '22 09:10 github-actions[bot]

@gorhom Hey, any news on the proposal ?

magrinj avatar Nov 29 '22 09:11 magrinj

Up

90dy avatar Dec 13 '22 12:12 90dy

@magrinj Why was this closed?

ansh avatar Dec 15 '22 11:12 ansh

@ansh it was actually auto close by the bot, I'll try to propose something more generic next week 🙂

magrinj avatar Jan 22 '23 11:01 magrinj

I just spent 45 minutes debugging why the bottom sheet wasn't displaying. Finally it occurred to me it could be behind my fullScreenModal. Sure enough removing presentation: 'fullScreenModal' for the Stack.Group my view is part of fixed it.

Not having a fix for this means we have to declare another BottomSheetModalProvider inside the view that presents the modal. However that means we can't use native headers in these views, otherwise the backdrop is rendered behind the native header.

mjvestal avatar Feb 14 '23 21:02 mjvestal

Just in case anyone else tries this - this doesn't seem to resolve the same issue on Android, even though it does on iOS. Use case was trying to display the bottom sheet over top of the built-in RN modal.

zibs avatar Mar 01 '23 16:03 zibs

Humm strange I'm using it on both platform for my app and it works well. Do you have a code sample ? I'll try to change my PR at the end of the week to avoid requiring the peerDependencies

magrinj avatar Mar 01 '23 17:03 magrinj

I don't have a repro I can share at the moment, but when I dig into the source for the overlay I see it's just on view on Android https://github.com/software-mansion/react-native-screens/blob/5d0f166d92c684188f218dd10ac933cf51489d28/src/index.native.tsx#LL377 and that's probably why it's not positioned on top of the native RN modal....

zibs avatar Mar 01 '23 18:03 zibs

Yes it's just a View on Android because it's actually not needed on that platform, the bottom sheet should appear above the other view without extra change. It's not the case on your side ?

magrinj avatar Mar 01 '23 21:03 magrinj

I've created this PR #1309, now react-native-screens is no longer a required peer dependency @gorhom. Sorry for the duplicate, I've removed the last fork

magrinj avatar Mar 02 '23 09:03 magrinj

Try to use containedTransparentModal instead of 'transparentModal' (https://reactnavigation.org/docs/native-stack-navigator/#presentation)

ktarasenkodel avatar Nov 01 '23 16:11 ktarasenkodel