From 7c426f9efc3561e5b1f36b137621228664f179dc Mon Sep 17 00:00:00 2001 From: "K. P. Sroka" Date: Fri, 16 Feb 2018 12:36:01 +0100 Subject: [PATCH] fix: disabling Touchables if onPress was not set to allow event handling in parent components --- example/src/ButtonExample.js | 31 ++++++++++++++++++++----------- src/components/DrawerItem.js | 3 +-- src/components/TouchableRipple.js | 11 ++++++++++- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/example/src/ButtonExample.js b/example/src/ButtonExample.js index 2e7e3aa019..efc8ede4f3 100644 --- a/example/src/ButtonExample.js +++ b/example/src/ButtonExample.js @@ -30,21 +30,29 @@ class ButtonExample extends React.Component { return ( - - - + + + - - + - - + - - - - diff --git a/src/components/DrawerItem.js b/src/components/DrawerItem.js index 8db591ab11..ab28181cd1 100644 --- a/src/components/DrawerItem.js +++ b/src/components/DrawerItem.js @@ -55,7 +55,6 @@ const DrawerItem = ({ icon, label, active, - onPress, theme, ...props }: Props) => { @@ -76,7 +75,7 @@ const DrawerItem = ({ const fontFamily = theme.fonts.medium; const labelMargin = icon ? 32 : 0; return ( - + {icon && } { style, background, borderless, + disabled: disabledProp, rippleColor, underlayColor, children, ...rest } = this.props; + const disabled = disabledProp || !this.props.onPress; + if ( Platform.OS === 'android' && Platform.Version >= ANDROID_VERSION_LOLLIPOP @@ -82,6 +89,7 @@ export default class TouchableRipple extends React.Component { return ( { /* $FlowFixMe */