Skip to content
Permalink
Browse files

Fix onLayout support in <TextInput>

Summary:
The `onLayout` prop is overridden by `<TouchableWithoutFeedback>` and thus does not work on `<TextInput>` components. https://github.com/facebook/react-native/blob/fb0007d85323909ab652bf97166744fa7e17daab/Libraries/Components/Touchable/TouchableWithoutFeedback.js#L176

This makes it so the following works.

```javascript
<TextInput onLayout={...} />
```

I only tested on iOS but I assume a similar fix might be needed for Android. https://github.com/facebook/react-native/blob/fb0007d85323909ab652bf97166744fa7e17daab/Libraries/Components/TextInput/TextInput.js#L575

**Test Plan**

https://rnplay.org/apps/euIZtg (confirm bug)
With fix, set `onLayout` on `<TextInput>` and see it is fired correctly.

```javascript
<TextInput onLayout={function(e) { console.log(e.nativeEvent); }} />
```
Closes #8042

Differential Revision: D3417192

fbshipit-source-id: 536ec81d3479e6bda474ac766b27afb39242c01a
  • Loading branch information
paulshen authored and Facebook Github Bot 6 committed Jun 10, 2016
1 parent 13dfb62 commit 92926f9858c0b60cf9f2e51cb8f25f2e1501c9c1
Showing with 1 addition and 0 deletions.
  1. +1 −0 Libraries/Components/TextInput/TextInput.js
@@ -501,6 +501,7 @@ var TextInput = React.createClass({

return (
<TouchableWithoutFeedback
onLayout={props.onLayout}
onPress={this._onPress}
rejectResponderTermination={true}
accessible={props.accessible}

0 comments on commit 92926f9

Please sign in to comment.
You can’t perform that action at this time.