Skip to content

Commit 3756d41

Browse files
sahrensfacebook-github-bot
authored andcommitted
Add testOnly_pressed to TouchableHighlight
Reviewed By: yungsters Differential Revision: D7043098 fbshipit-source-id: 1df06df6820d81b37dc9a167a7931ed20df44f0f
1 parent ebbd437 commit 3756d41

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

Libraries/Components/Touchable/TouchableHighlight.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ const TouchableHighlight = createReactClass({
176176
* @platform ios
177177
*/
178178
tvParallaxProperties: PropTypes.object,
179+
/**
180+
* Handy for snapshot tests.
181+
*/
182+
testOnly_pressed: PropTypes.bool,
179183
},
180184

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

185189
getInitialState: function() {
186190
this._isMounted = false;
187-
return {
188-
...this.touchableGetInitialState(),
189-
extraChildStyle: null,
190-
extraUnderlayStyle: null,
191-
};
191+
if (this.props.testOnly_pressed) {
192+
return {
193+
...this.touchableGetInitialState(),
194+
extraChildStyle: {
195+
opacity: this.props.activeOpacity,
196+
},
197+
extraUnderlayStyle: {
198+
backgroundColor: this.props.underlayColor,
199+
},
200+
};
201+
} else {
202+
return {
203+
...this.touchableGetInitialState(),
204+
extraChildStyle: null,
205+
extraUnderlayStyle: null,
206+
};
207+
}
192208
},
193209

194210
componentDidMount: function() {
@@ -280,6 +296,9 @@ const TouchableHighlight = createReactClass({
280296
_hideUnderlay: function() {
281297
clearTimeout(this._hideTimeout);
282298
this._hideTimeout = null;
299+
if (this.props.testOnly_pressed) {
300+
return;
301+
}
283302
if (this._hasPressHandler()) {
284303
this.setState({
285304
extraChildStyle: null,

0 commit comments

Comments
 (0)