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

backdrop is not removing when I close the sheet

Open RutvinBhanderi opened this issue 3 years ago • 10 comments

Bug

I have given containerStyle to bottom sheet but when I close the sheet container is not closing, the style is still there. <BottomSheet ref={bottomSheetRef} index={-1} snapPoints={snapPoints} containerStyle={{ backgroundColor:'rgba(0,0,0,0.3)' }} handleIndicatorStyle={{ width: 100, }} > when I close sheet container is removing. Simulator Screen Shot - iPhone 14 Pro Max - 2023-03-06 at 16 57 55

Simulator Screen Shot - iPhone 14 Pro Max - 2023-03-06 at 16 58 01

Environment info

Library Version
@gorhom/bottom-sheet 4.4.5
react-native 0.69.4
react-native-reanimated 2.10.0
react-native-gesture-handler 2.6.1

Steps To Reproduce

Describe what you expected to happen:

  1. don't want container when sheet is closed

Reproducible sample code

RutvinBhanderi avatar Mar 06 '23 11:03 RutvinBhanderi

@RutvinBhanderi: hello! :wave:

This issue is being automatically closed because it does not follow the issue template.

github-actions[bot] avatar Mar 06 '23 11:03 github-actions[bot]

i have the same problem, and i dont know if its a bug or something that im doing wrong

EduuLucas avatar Mar 06 '23 16:03 EduuLucas

Add the BottomSheetBackdrop imported from @gorhom/bottom-sheet and pass dissappearsOnIndex={-1}

 <BottomSheet
            ref={ref}
            index={-1}
            enablePanDownToClose
            **backdropComponent={(backdropProps) => <BottomSheetBackdrop {...backdropProps} disappearsOnIndex={-1} />}**
            backgroundStyle={{ backgroundColor: theme.colors.background }}
            handleIndicatorStyle={{ backgroundColor: theme.colors.text }}
        >

Cosmind0 avatar Mar 27 '23 21:03 Cosmind0

@Cosmind0 We have imported the backdrop from the library and have added disappearsOnIndex as well but it still fails with Reanimated v3 and more. Can you please help? @gorhom

@RutvinBhanderi Did u find the solution?

malikzype avatar Apr 24 '23 07:04 malikzype

@Cosmind0 We have imported the backdrop from the library and have added disappearsOnIndex as well but it still fails with Reanimated v3 and more. Can you please help? @gorhom

@RutvinBhanderi Did u find the solution?

You can create custom backdrop like this and it worked for me import { BottomSheetBackdrop, } from "@gorhom/bottom-sheet"; import React from "react";

const CustomBackdrop = (props) => { return ( <BottomSheetBackdrop {...props} pressBehavior="none" disappearsOnIndex={-1} appearsOnIndex={0} enableTouchThrough={false} opacity={0.4} /> ); }; export default CustomBackdrop;

RutvinBhanderi avatar Apr 24 '23 07:04 RutvinBhanderi

@malikzype And I'm pretty sure that you don't need to add the background to the containerStyle, you need to do it like this backgroundStyle={{ backgroundColor: 'rgba(0,0,0,0.3)'}}. Not sure though, I haven't tried to do it with containerStyle

Cosmind0 avatar Apr 24 '23 07:04 Cosmind0

@Cosmind0 @RutvinBhanderi We have created our custom backdrop component. It works fine with Reanimated version >3. In version 3 of reanimated the keyboard calls on the onClose method of the bottom sheet and in some scenarios, it leaves the backdrop component as is which creates the issue.

malikzype avatar Apr 24 '23 09:04 malikzype

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

github-actions[bot] avatar May 25 '23 09:05 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar May 30 '23 09:05 github-actions[bot]

this issues still persist.

eoluwakayode34 avatar Mar 20 '24 06:03 eoluwakayode34