From 274f5b879f8d6c8d6b2ba3de8b6da50cfa2dc461 Mon Sep 17 00:00:00 2001 From: Taylor123 Date: Thu, 6 Dec 2018 21:29:48 -0800 Subject: [PATCH] default hitSlop values to 0 (#22281) Summary: Experienced a `TouchableOpacity` releasing the `PanResponder` without invoking `onPress` due to a missing a direction key in the `hitSlop` prop; The missing key caused the corresponding pressExpand to become NaN which causes `isTouchWithinActive` to become falsey, when it should be truthy. If defaulting to 0 is undesired behavior, I'm happy to take a different approach. Pull Request resolved: https://github.com/facebook/react-native/pull/22281 Differential Revision: D13374335 Pulled By: cpojer fbshipit-source-id: f9d28e51b9d9c45aed42bea2df3d844a799fa827 --- Libraries/Components/Touchable/Touchable.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index 3f1874c8aac..fe3360ed953 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -480,10 +480,10 @@ const TouchableMixin = { : null; if (hitSlop) { - pressExpandLeft += hitSlop.left; - pressExpandTop += hitSlop.top; - pressExpandRight += hitSlop.right; - pressExpandBottom += hitSlop.bottom; + pressExpandLeft += hitSlop.left || 0; + pressExpandTop += hitSlop.top || 0; + pressExpandRight += hitSlop.right || 0; + pressExpandBottom += hitSlop.bottom || 0; } const touch = TouchEventUtils.extractSingleTouch(e.nativeEvent);