onBackdropPress not functioning as expected on Android
See original GitHub issueSo I’ve been trying to use the newly implemented onBackdropPress to close a modal when the backdrop is pressed. As it wasn’t working originally, I decided to replace the functionality with a console log to see when onBackdropPress is being called.
From what I can see, the only times it’s firing off are when I open the modal originally, and when I close the modal using onBackButtonPress. Nothing seems to be triggered when I tap the modal itself.
I’ve attempted to move the modal to different levels in component structure (I have a number of child components and ideally wanted to call it from the very last child), but it seems to function the same regardless of where it is.
My usage of the modal looks like this:
<Modal
isVisible = {this.props.visible}
backdropColor = 'red'
onBackdropPress = {console.log("Pressed")}
onBackButtonPress = {this.props.closeModal}>
<View style = {styles.modalView}>
...
</View>
</Modal>
Dependencies in use: react-native-modal 3.1.0. react 16.0.0-alpha.12 react-native 0.47.2
I’m running on a Samsung Galaxy S5.
Here’s a link to a basic expo app which shows the issue: https://github.com/vanhoutk/modaltest
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Thanks, the following won’t work though:
Try replacing it with:
Let me know if the issue still persists.
Also, does the provided eximple work for you? https://github.com/react-native-community/react-native-modal/tree/master/example/src
@vanhoutk that call would happen anytime the component is mounted - console.log is called, and the resulting value (null) is set to onBackdropPress.