From c1223c553004a7628e22555d0ebac40581cba261 Mon Sep 17 00:00:00 2001 From: dlowder-salesforce Date: Wed, 18 Oct 2017 12:16:31 -0700 Subject: [PATCH] Apple TV: TouchableOpacity and Button need hasTVPreferredFocus support Summary: **Motivation** Give `TouchableOpacity` and `Button` the same TV focus support as is already present in `TouchableHighlight`. **Test plan** Manual testing on TV simulator and devices. Closes https://github.com/facebook/react-native/pull/15561 Differential Revision: D5665976 Pulled By: hramos fbshipit-source-id: 0d5c588e1c82471f23617a3df1b77abc589a7c63 --- Libraries/Components/Button.js | 9 +++++++++ Libraries/Components/Touchable/TouchableOpacity.js | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/Libraries/Components/Button.js b/Libraries/Components/Button.js index 9729f8832..fc3f2ef5a 100644 --- a/Libraries/Components/Button.js +++ b/Libraries/Components/Button.js @@ -58,6 +58,7 @@ class Button extends React.Component<{ accessibilityLabel?: ?string, disabled?: ?boolean, testID?: ?string, + hasTVPreferredFocus?: ?boolean, }> { static propTypes = { /** @@ -84,6 +85,12 @@ class Button extends React.Component<{ * Used to locate this view in end-to-end tests. */ testID: PropTypes.string, + /** + * *(Apple TV only)* TV preferred focus (see documentation for the View component). + * + * @platform ios + */ + hasTVPreferredFocus: PropTypes.bool, }; render() { @@ -92,6 +99,7 @@ class Button extends React.Component<{ color, onPress, title, + hasTVPreferredFocus, disabled, testID, } = this.props; @@ -121,6 +129,7 @@ class Button extends React.Component<{ accessibilityComponentType="button" accessibilityLabel={accessibilityLabel} accessibilityTraits={accessibilityTraits} + hasTVPreferredFocus={hasTVPreferredFocus} testID={testID} disabled={disabled} onPress={onPress}> diff --git a/Libraries/Components/Touchable/TouchableOpacity.js b/Libraries/Components/Touchable/TouchableOpacity.js index 4a46cdab9..1dced65d6 100644 --- a/Libraries/Components/Touchable/TouchableOpacity.js +++ b/Libraries/Components/Touchable/TouchableOpacity.js @@ -129,6 +129,12 @@ var TouchableOpacity = createReactClass({ * active. Defaults to 0.2. */ activeOpacity: PropTypes.number, + /** + * *(Apple TV only)* TV preferred focus (see documentation for the View component). + * + * @platform ios + */ + hasTVPreferredFocus: PropTypes.bool, /** * Apple TV parallax effects */ @@ -246,6 +252,7 @@ var TouchableOpacity = createReactClass({ testID={this.props.testID} onLayout={this.props.onLayout} isTVSelectable={true} + hasTVPreferredFocus={this.props.hasTVPreferredFocus} tvParallaxProperties={this.props.tvParallaxProperties} hitSlop={this.props.hitSlop} onStartShouldSetResponder={this.touchableHandleStartShouldSetResponder}