-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Fix Pressables not being tappable in PanResponder Views on Android #29533
Conversation
Base commit: d48f7ba |
Base commit: d48f7ba |
On further experimenting, it looks like iOS has the same behaviour as the existing (pre-PR) Android behaviour. I'm going to close this. I think we're supposed to just put this logic in the PanResponder |
Thanks for this! The solution is simple on js side: PanResponder.create({
onMoveShouldSetPanResponder: Platform.select({
default: () => true,
android: (e: GestureResponderEvent, state: PanResponderGestureState) =>
Math.abs(state.dx) > 10 || Math.abs(state.dy) > 10
})
}) |
thanks, it solves my problem |
I would like to try this because I am having the same issue with onPress inside Animated view using pan responder but on vscode I am having error saying
Currently I am using .js file. How to change this to js format? thanks. |
Summary
This fix makes Touchables and Pressables touchable, even if they're inside another view with a PanResponder/GestureResponder that handles touches.
I have an app that had a
TouchableWithoutFeedback
inside of aView
with a PanResponder attached. The TouchableWithoutFeedback received touches as expected on iOS, but not on Android.Debugging
onResponderTerminationRequest
MotionEvent
handlerRoot cause
After debugging, I realized this is because on Android (tested on Pixel 2 device):
topTouchMove
event is emitted from native code, even if the user doesn't move their finger at allThis is unintuitive. Instead, the
topTouchMove
event should only be emitted when some actual move happens, like on iOS.Fix
To fix this, I added code to only emit a touchMove event if the user's touch has moved at least 10 units away from where it started. This code was based on other code in Pressability that also use this threshold.
Changelog
[Android] [Fixed] - Fix Pressables not being tappable in PanResponder Views on Android
Test Plan
Added a test case in RNTesterApp's Pressable screen: