Skip to content

Apple TV: TouchableOpacity and Button need hasTVPreferredFocus support #15561

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Libraries/Components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Button extends React.Component<{
accessibilityLabel?: ?string,
disabled?: ?boolean,
testID?: ?string,
hasTVPreferredFocus?: ?boolean,
}> {
static propTypes = {
/**
Expand All @@ -81,6 +82,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() {
Expand All @@ -89,6 +96,7 @@ class Button extends React.Component<{
color,
onPress,
title,
hasTVPreferredFocus,
disabled,
testID,
} = this.props;
Expand Down Expand Up @@ -118,6 +126,7 @@ class Button extends React.Component<{
accessibilityComponentType="button"
accessibilityLabel={accessibilityLabel}
accessibilityTraits={accessibilityTraits}
hasTVPreferredFocus={hasTVPreferredFocus}
testID={testID}
disabled={disabled}
onPress={onPress}>
Expand Down
7 changes: 7 additions & 0 deletions Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,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
*/
Expand Down Expand Up @@ -180,6 +186,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}
Expand Down