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

Bottom Sheet doesn't overlay the Tab Bar in Bottom Tabs navigator

Open Riverknight0 opened this issue 2 years ago • 12 comments

Thanks for this wonderful, easy to use library. 

There is a small thing i faced. 

How can we show bottom sheet over/in the foreground of Bottom Tabs Navigator (React navigation v6. in this case)

I want to show only bottom sheet and not bottom navigator.

Riverknight0 avatar Dec 28 '23 20:12 Riverknight0

I'm assuming you meant overlaying the bottom tab bar??

How does it look when it opens currently?

stanleyugwu avatar Jan 03 '24 03:01 stanleyugwu

Hey! I'm testing this library to use it on my app. But i experienced this issue too. I'd really like to have this fixed because it's the best library i found

image

fernandasecinaro avatar Feb 07 '24 03:02 fernandasecinaro

Thanks for providing this image @fernandasecinaro

Just fyi, this is not an issue with the sheet itself but the expected behavior for bottom tab navigator because the screens and the navigator elements (tab bar) are not in same view hierarchy.

Assume the tab bar to be fixed in position and renders above the screen (which is where the sheet is). So the sheet overlays the screen content, but tab bar overlays everything.

That said, I'll look into finding a solution for this.

Also the comment is open for suggestions

stanleyugwu avatar Feb 08 '24 16:02 stanleyugwu

Agree on this - can't wait for it to get fixed. Any workaround?

MathiasSvDK avatar Feb 17 '24 22:02 MathiasSvDK

@Riverknight0 @fernandasecinaro @MathiasSvDK

A possible workaround I can think of is hiding the tab bar when sheet opens and showing it back when sheet closes. This an be done using onClose and onOpen props along with useNavigation hook.

Example:

import { useNavigation } from "@react-navigation/native"; // or from 'expo-router'
...
const navigation = useNavigation();

<BottomSheet
    ref={sheetRef}
    onOpen={() =>
      navigation.setOptions({ tabBarStyle: { display: "none" } })
    }
    onClose={() =>
      navigation.setOptions({ tabBarStyle: { display: "flex" } })
    }
>
...
</BottomSheet>

stanleyugwu avatar Feb 19 '24 10:02 stanleyugwu

You can use portal (https://github.com/jeremybarbet/react-native-portalize for example) to teleport your modal before your navigation tab bar.

TomCorvus avatar Mar 02 '24 07:03 TomCorvus

@TomCorvus Thank you so much for this, I'll test it out pretty soon and if it works well, then you would've saved me from a lot of headaches 😀

stanleyugwu avatar Mar 02 '24 10:03 stanleyugwu

@stanleyugwu Any update?

Goktug avatar Mar 21 '24 07:03 Goktug

@Goktug you can use react-native-portalize for now.

I’m looking at replicating what’s done in the library inside the bottom sheet so users won’t have to install another package to solve the problem.

But y’all please use react-native-portalize for now.

stanleyugwu avatar Mar 21 '24 12:03 stanleyugwu

I think I’ll keep this open till we have a built in solution.

stanleyugwu avatar Mar 21 '24 12:03 stanleyugwu