Skip to content

Commit

Permalink
Add testOnly_pressed to TouchableHighlight
Browse files Browse the repository at this point in the history
Reviewed By: yungsters

Differential Revision: D7043098

fbshipit-source-id: 1df06df6820d81b37dc9a167a7931ed20df44f0f
  • Loading branch information
sahrens authored and facebook-github-bot committed Feb 26, 2018
1 parent ebbd437 commit 3756d41
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions Libraries/Components/Touchable/TouchableHighlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ const TouchableHighlight = createReactClass({
* @platform ios
*/
tvParallaxProperties: PropTypes.object,
/**
* Handy for snapshot tests.
*/
testOnly_pressed: PropTypes.bool,
},

mixins: [NativeMethodsMixin, Touchable.Mixin],
Expand All @@ -184,11 +188,23 @@ const TouchableHighlight = createReactClass({

getInitialState: function() {
this._isMounted = false;
return {
...this.touchableGetInitialState(),
extraChildStyle: null,
extraUnderlayStyle: null,
};
if (this.props.testOnly_pressed) {
return {
...this.touchableGetInitialState(),
extraChildStyle: {
opacity: this.props.activeOpacity,
},
extraUnderlayStyle: {
backgroundColor: this.props.underlayColor,
},
};
} else {
return {
...this.touchableGetInitialState(),
extraChildStyle: null,
extraUnderlayStyle: null,
};
}
},

componentDidMount: function() {
Expand Down Expand Up @@ -280,6 +296,9 @@ const TouchableHighlight = createReactClass({
_hideUnderlay: function() {
clearTimeout(this._hideTimeout);
this._hideTimeout = null;
if (this.props.testOnly_pressed) {
return;
}
if (this._hasPressHandler()) {
this.setState({
extraChildStyle: null,
Expand Down

0 comments on commit 3756d41

Please sign in to comment.