From f002fda275872507464c0191f818765eba41d5dd Mon Sep 17 00:00:00 2001 From: James Ide Date: Wed, 18 Mar 2015 12:22:56 -0700 Subject: [PATCH] [TouchableHighlight] Preserve underlay style when restoring inactive props Summary: If you give a TouchableHighlight component some styling (e.g. a background color) with the `underlayStyle` prop, the style is wiped away after touching the component. This diff restores the `underlayStyle`. Closes https://github.com/facebook/react-native/pull/129 Github Author: James Ide Test Plan: Create a TouchableHighlight that receives `underlayStyle={{style: 'blue'}}`. It initially has a blue background. Touch it and let go. See the blue background now comes back as expected. --- Libraries/Components/Touchable/TouchableHighlight.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/Touchable/TouchableHighlight.js b/Libraries/Components/Touchable/TouchableHighlight.js index 11b7a6a475541d..9bb539cebab86e 100644 --- a/Libraries/Components/Touchable/TouchableHighlight.js +++ b/Libraries/Components/Touchable/TouchableHighlight.js @@ -159,7 +159,10 @@ var TouchableHighlight = React.createClass({ this._hideTimeout = null; if (this.refs[UNDERLAY_REF]) { this.refs[CHILD_REF].setNativeProps(INACTIVE_CHILD_PROPS); - this.refs[UNDERLAY_REF].setNativeProps(INACTIVE_UNDERLAY_PROPS); + this.refs[UNDERLAY_REF].setNativeProps({ + ...INACTIVE_UNDERLAY_PROPS, + style: this.state.underlayStyle, + }); } },