Skip to content

Commit 67fc47f

Browse files
committed
Add onFocus / onBlur event listeners only for TV
1 parent d396f69 commit 67fc47f

File tree

2 files changed

+10
-4
lines changed
  • packages/react-native-web/src/exports

2 files changed

+10
-4
lines changed

packages/react-native-web/src/exports/TouchableHighlight/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ const TouchableHighlight = ((createReactClass({
329329

330330
render: function() {
331331
const child = React.Children.only(this.props.children);
332+
// Add this event listeners only for TVs
333+
const onBlur = Platform.isTV ? { onBlur: this.touchableHandleBlur } : {};
334+
const onFocus = Platform.isTV ? { onFocus: this.touchableHandleFocus } : {};
332335
return (
333336
<View
334337
{...this.props}
@@ -342,8 +345,8 @@ const TouchableHighlight = ((createReactClass({
342345
nativeID={this.props.nativeID}
343346
//isTVSelectable={true}
344347
//tvParallaxProperties={this.props.tvParallaxProperties}
345-
onBlur={this.touchableHandleBlur}
346-
onFocus={this.touchableHandleFocus}
348+
{...onBlur}
349+
{...onFocus}
347350
onKeyDown={this.touchableHandleKeyEvent}
348351
//nextFocusDown={this.props.nextFocusDown}
349352
//nextFocusForward={this.props.nextFocusForward}

packages/react-native-web/src/exports/TouchableOpacity/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ const TouchableOpacity = ((createReactClass({
282282
},
283283

284284
render: function() {
285+
// Add this event listeners only for TVs
286+
const onBlur = Platform.isTV ? { onBlur: this.touchableHandleBlur } : {};
287+
const onFocus = Platform.isTV ? { onFocus: this.touchableHandleFocus } : {};
285288
return (
286289
<View
287290
{...this.props}
@@ -293,8 +296,8 @@ const TouchableOpacity = ((createReactClass({
293296
hasTVPreferredFocus={this.props.hasTVPreferredFocus}
294297
hitSlop={this.props.hitSlop}
295298
nativeID={this.props.nativeID}
296-
onBlur={this.touchableHandleBlur}
297-
onFocus={this.touchableHandleFocus}
299+
{...onBlur}
300+
{...onFocus}
298301
onKeyDown={this.touchableHandleKeyEvent}
299302
//isTVSelectable={true}
300303
//nextFocusDown={this.props.nextFocusDown}

0 commit comments

Comments
 (0)