Permalink
Browse files

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 #15561

Differential Revision: D5665976

Pulled By: hramos

fbshipit-source-id: 0d5c588e1c82471f23617a3df1b77abc589a7c63
  • Loading branch information...
dlowder-salesforce authored and facebook-github-bot committed Oct 18, 2017
1 parent 52a67db commit c1223c553004a7628e22555d0ebac40581cba261
Showing with 16 additions and 0 deletions.
  1. +9 −0 Libraries/Components/Button.js
  2. +7 −0 Libraries/Components/Touchable/TouchableOpacity.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}>
@@ -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}

0 comments on commit c1223c5

Please sign in to comment.