Skip to content

Commit

Permalink
Don't show underlay if no press handlers
Browse files Browse the repository at this point in the history
Reviewed By: sahrens

Differential Revision: D2915003

fb-gh-sync-id: 56ba942ed464e393ea43229b1fa9ef6936a24ecc
shipit-source-id: 56ba942ed464e393ea43229b1fa9ef6936a24ecc
  • Loading branch information
Emily Janzer authored and facebook-github-bot-1 committed Feb 12, 2016
1 parent 194273f commit e93afad
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Libraries/Components/Touchable/TouchableHighlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ var TouchableHighlight = React.createClass({
},

_showUnderlay: function() {
if (!this.isMounted()) {
if (!this.isMounted() || !this._hasPressHandler()) {
return;
}

Expand All @@ -201,7 +201,7 @@ var TouchableHighlight = React.createClass({
_hideUnderlay: function() {
this.clearTimeout(this._hideTimeout);
this._hideTimeout = null;
if (this.refs[UNDERLAY_REF]) {
if (this._hasPressHandler() && this.refs[UNDERLAY_REF]) {
this.refs[CHILD_REF].setNativeProps(INACTIVE_CHILD_PROPS);
this.refs[UNDERLAY_REF].setNativeProps({
...INACTIVE_UNDERLAY_PROPS,
Expand All @@ -211,6 +211,15 @@ var TouchableHighlight = React.createClass({
}
},

_hasPressHandler: function() {
return !!(
this.props.onPress ||
this.props.onPressIn ||
this.props.onPressOut ||
this.props.onLongPress
);
},

render: function() {
return (
<View
Expand Down

0 comments on commit e93afad

Please sign in to comment.