From 21890e964df7674fcf13cefc8cb939441f6eddef Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 23 Sep 2019 14:44:36 -0700 Subject: [PATCH] Fix onPress prop for Touchable Components being called twice on Android Tv (#26474) Summary: Due to an update to react-native on the android tv platform tapping the select button on a remote calls the onPress prop twice for `TouchableHighlight`, `TouchableOpacity`, and `TouchableWithoutFeedback`. This is happening because touchableHandlePress gets called from two places. First from the onClick prop in the touchable component and second from the TVEventHandler in the TouchableMixin. ## Changelog [Android] [Fixed] - Adds a not android check to the select case of the TVEventHandler callback in the TouchableMixin. Pull Request resolved: https://github.com/facebook/react-native/pull/26474 Test Plan: Confirmed on Android Tv and Apple Tv 1) Add a TouchableOpacity to a screen with an onPress callback 2) Run app 3) Focus the TouchableOpacity 4) Press the Select Button on the Remote **Expected Results** onPress is called once Differential Revision: D17530170 Pulled By: TheSavior fbshipit-source-id: b776faba477c6231ad296abd21f072335dca5556 --- Libraries/Components/Touchable/Touchable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index 2e39937dce2..e589b6adde8 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -380,7 +380,7 @@ const TouchableMixin = { cmp.touchableHandleFocus(evt); } else if (evt.eventType === 'blur') { cmp.touchableHandleBlur(evt); - } else if (evt.eventType === 'select') { + } else if (evt.eventType === 'select' && Platform.OS !== 'android') { cmp.touchableHandlePress && !cmp.props.disabled && cmp.touchableHandlePress(evt);