-
-
Notifications
You must be signed in to change notification settings - Fork 955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-native-gesture-handler cancels presses on normal react-native touchables. #920
Comments
I am able to replicate the behavior I am having trouble with in the I am testing in the Before any modifications both the RN and GH Touchables call all three callbacks as expected:
In the Touchables return (
<Component style={{ width: '100%', height: '100%', padding: 10 }}>
<TouchableOpacity onPress={this.toggleScrollView}>
<Text>
Use {this.state.useScrollView ? 'View' : 'ScrollView'} as a wrapper
</Text>
</TouchableOpacity>
<Text>{text}</Text>
<TapGestureHandler>{/* Added handler here to simulate how react-native-draggable-flatlist renders items */}
<View
style={{
justifyContent: 'space-between',
flexDirection: 'row',
margin: 20,
}}>
<RNTouchable
{...props}
background={background && background(RNTouchableNativeFeedback)}>
{renderChild(color)}
</RNTouchable>
<GHTouchable
{...props}
background={background && background(TouchableNativeFeedback)}>
{renderChild(color)}
</GHTouchable>
</View>
</TapGestureHandler>{/* Added */}
</Component>
); After this change, the RNTouchable no longer calls
However, when holding the press long enough to trigger a "long" press, |
However, setting a short (10ms) |
Sorry, @osdnk it would be great if anybody could investigate this one, important for me too. |
I was having the same issue and then by removing the useScreen() function from react-navigation, all the touches on Android went through. It might be helpful to note it. |
Hi! I tried it on Gesture Handler 2.4.2 and I believe it works correctly, using both import React from 'react';
import { StyleSheet, View, TouchableOpacity } from 'react-native';
import { GestureDetector, Gesture } from 'react-native-gesture-handler';
export default function Example() {
const gesture = Gesture.Tap().onEnd(() => {
console.log('tap');
});
return (
<View style={styles.view}>
<GestureDetector gesture={gesture}>
<TouchableOpacity
onPressIn={() => console.log('press in')}
onPressOut={() => console.log('press out')}
onPress={() => console.log('press')}>
<View style={styles.box} />
</TouchableOpacity>
</GestureDetector>
</View>
);
}
const styles = StyleSheet.create({
view: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
box: {
width: 150,
height: 150,
backgroundColor: 'mediumspringgreen',
margin: 10,
zIndex: 200,
},
}); |
I am trying to use react-native-draggable-flatlist, which uses
react-native-gesture-handler
.It wraps each flat list item in a
TagGestureHandler
. Inside these items I have buttons that are using normalreact-native
TouchableOpacity
.This works fine on iOS.
On Android,
onPress
seems to be cancelled for theseTouchableOpacity
buttons.If I tap normally
onPress
is NOT called.However, if I tap somewhat slowly, but NOT necessarily a "long" press,
onPress
DOES get called.What is the expected behavior when using RN Touchables within GestureHandlers? Is there a work around I could use to stop this unexpected behavior?
The text was updated successfully, but these errors were encountered: