Skip to content

feat(BottomSheet): add onBackdropPress handler#3074

Merged
arpitBhalla merged 12 commits intoreact-native-elements:nextfrom
kedar09:bottomsheet_onBackdropPress
Feb 5, 2022
Merged

feat(BottomSheet): add onBackdropPress handler#3074
arpitBhalla merged 12 commits intoreact-native-elements:nextfrom
kedar09:bottomsheet_onBackdropPress

Conversation

@kedar09
Copy link
Copy Markdown
Contributor

@kedar09 kedar09 commented Jun 9, 2021

What kind of change does this PR introduce?

I have added the onBackdropPress function for close bottomsheet.

Did you add tests for your changes?
Yes
If relevant, did you update the documentation?

Summary

I have used react-native-elements package and I need the onBackdropPress function for bottomsheet like in overlay onBackdropPress

Does this PR introduce a breaking change?
No

Other information

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 9, 2021

Codecov Report

Merging #3074 (5327822) into next (f859d68) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 5327822 differs from pull request most recent head 5c1a6a5. Consider uploading reports for the commit 5c1a6a5 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             next    #3074      +/-   ##
==========================================
+ Coverage   79.96%   79.97%   +0.01%     
==========================================
  Files          88       88              
  Lines        1662     1663       +1     
  Branches      731      732       +1     
==========================================
+ Hits         1329     1330       +1     
  Misses        328      328              
  Partials        5        5              
Impacted Files Coverage Δ
packages/base/src/BottomSheet/BottomSheet.tsx 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a173d1...5c1a6a5. Read the comment docs.

Copy link
Copy Markdown
Member

@khushal87 khushal87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve merge conflicts.

Comment on lines +41 to +50
<TouchableWithoutFeedback
onPress={onBackdropPress}
testID="RNE__Overlay__backdrop"
>
<View
testID="backdrop"
style={StyleSheet.flatten([styles.backdrop, backdropStyle])}
/>
</TouchableWithoutFeedback>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use Pressable?

TouchableWithoutFeedback to Pressable
@kedar09
Copy link
Copy Markdown
Contributor Author

kedar09 commented Jul 8, 2021

@kedar09 Can you resolve conflict
I have updated the code with the latest code in the next branch and push that changes

@jorgegvallejo
Copy link
Copy Markdown
Contributor

Hope this gets added to the next release 🙏

Copy link
Copy Markdown
Collaborator

@flyingcircle flyingcircle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this in the demo app. Did not work.

@arpitBhalla
Copy link
Copy Markdown
Member

arpitBhalla commented Aug 10, 2021

We need to use pointerEvents

diff --git a/src/BottomSheet/BottomSheet.tsx b/src/BottomSheet/BottomSheet.tsx
index fb5019c3f..32edd5468 100644
--- a/src/BottomSheet/BottomSheet.tsx
+++ b/src/BottomSheet/BottomSheet.tsx
@@ -28,6 +28,8 @@ export type BottomSheetProps = {
 
   /** Is the modal component shown. */
   isVisible?: boolean;
+
+  /** Props for ScrollView */
   scrollViewProps?: ScrollViewProps;
 };
 
@@ -54,14 +56,13 @@ export const BottomSheet: RneFunctionComponent<BottomSheetProps> = ({
       visible={isVisible}
       {...modalProps}
     >
-      <Pressable onPress={onBackdropPress} testID="RNE__Overlay__backdrop">
-        <View
-          testID="backdrop"
-          style={StyleSheet.flatten([styles.backdrop, backdropStyle])}
-        />
-      </Pressable>
-
+      <Pressable
+        style={[StyleSheet.absoluteFill, styles.backdrop, backdropStyle]}
+        onPress={onBackdropPress}
+        testID="RNE__Overlay__backdrop"
+      />
       <SafeAreaView
+        pointerEvents={'none'}
         style={StyleSheet.flatten([
           styles.safeAreaView,
           containerStyle && containerStyle,
~
~
~
(END)

@kedar09
Copy link
Copy Markdown
Contributor Author

kedar09 commented Aug 11, 2021

pointerEvents={'none'}

@arpitBhalla i have used
style={[StyleSheet.absoluteFill, styles.backdrop, backdropStyle]}
and pointerEvents="box-none"
its worked


return (<Modal onRequestClose={onBackdropPress} animationType="slide" transparent={true} visible={isVisible} {...modalProps}>
    <Pressable onPress={onBackdropPress}   
    style={[StyleSheet.absoluteFill, styles.backdrop, backdropStyle]}
     testID="RNE__Overlay__backdrop" />
    
      <SafeAreaView style={StyleSheet.flatten([
        styles.safeAreaView,
        containerStyle && containerStyle,
    ])} {...props} pointerEvents="box-none">
        <View>
          <ScrollView {...scrollViewProps}>{children}</ScrollView>
        </View>
      </SafeAreaView>
    </Modal>);

@netlify
Copy link
Copy Markdown

netlify bot commented Aug 12, 2021

✔️ Deploy Preview for react-native-elements canceled.

🔨 Explore the source changes: 7a5e406

🔍 Inspect the deploy log: https://app.netlify.com/sites/react-native-elements/deploys/612f867b21e9f7000872917e

@kedar09 kedar09 requested a review from flyingcircle August 12, 2021 10:33
@arpitBhalla arpitBhalla changed the title bottomsheet- added onBackdropPress for close bottomsheet feat(BottomSheet): add onBackdropPress handler Jan 25, 2022
@arpitBhalla arpitBhalla merged commit de1a02b into react-native-elements:next Feb 5, 2022
@arpitBhalla
Copy link
Copy Markdown
Member

Thank you for your contribution 🎉

@arpitBhalla arpitBhalla added this to the v4.0.0 milestone Feb 5, 2022
github-actions bot pushed a commit that referenced this pull request Feb 5, 2022
Co-authored-by: kedar09 <kedar@cleverground.com>
Co-authored-by: Arpit Bhalla <arpitbhalla2001@gmail.com>
github-actions bot pushed a commit that referenced this pull request Feb 5, 2022
Co-authored-by: kedar09 <kedar@cleverground.com>
Co-authored-by: Arpit Bhalla <arpitbhalla2001@gmail.com>
github-actions bot pushed a commit that referenced this pull request Feb 5, 2022
Co-authored-by: kedar09 <kedar@cleverground.com>
Co-authored-by: Arpit Bhalla <arpitbhalla2001@gmail.com>
@kedar09 kedar09 deleted the bottomsheet_onBackdropPress branch February 5, 2022 15:38
arpitBhalla added a commit that referenced this pull request Mar 17, 2022
Co-authored-by: kedar09 <kedar@cleverground.com>
Co-authored-by: Arpit Bhalla <arpitbhalla2001@gmail.com>
arpitBhalla added a commit that referenced this pull request Mar 19, 2022
Co-authored-by: kedar09 <kedar@cleverground.com>
Co-authored-by: Arpit Bhalla <arpitbhalla2001@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants