Permalink
Browse files

Add testOnly_pressed to TouchableHighlight

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 3756d41de1feb167482f01b26f9a5f2563ef8bff
Showing with 24 additions and 5 deletions.
  1. +24 −5 Libraries/Components/Touchable/TouchableHighlight.js
@@ -176,6 +176,10 @@ const TouchableHighlight = createReactClass({
* @platform ios
*/
tvParallaxProperties: PropTypes.object,
/**
* Handy for snapshot tests.
*/
testOnly_pressed: PropTypes.bool,
},
mixins: [NativeMethodsMixin, Touchable.Mixin],
@@ -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() {
@@ -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,

0 comments on commit 3756d41

Please sign in to comment.