Skip to content

Commit d720459

Browse files
committed
[TextInput] Add onLayout to TextInput, forwarding it to the native views
Summary: `TextInput` does not automatically forward all props using the spread operator so we need to explicitly forward the `onLayout` prop. Closes #1296 Github Author: James Ide <[email protected]> Test Plan: Mount a TextInput component with an `onLayout` prop and see that the callback handler is invoked with the TextInput's frame.
1 parent d27e6fa commit d720459

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Libraries/Components/TextInput/TextInput.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ var TextInput = React.createClass({
232232
* Callback that is called when the text input's submit button is pressed.
233233
*/
234234
onSubmitEditing: PropTypes.func,
235+
/**
236+
* Invoked on mount and layout changes with {x, y, width, height}.
237+
*/
238+
onLayout: PropTypes.func,
235239
/**
236240
* If true, the text input obscures the text entered so that sensitive text
237241
* like passwords stay secure. Default value is false.
@@ -446,6 +450,7 @@ var TextInput = React.createClass({
446450
onEndEditing={this.props.onEndEditing}
447451
onSubmitEditing={this.props.onSubmitEditing}
448452
onSelectionChangeShouldSetResponder={() => true}
453+
onLayout={this.props.onLayout}
449454
placeholder={this.props.placeholder}
450455
placeholderTextColor={this.props.placeholderTextColor}
451456
text={this.state.bufferedValue}
@@ -495,6 +500,7 @@ var TextInput = React.createClass({
495500
onSelectionChange={this._onSelectionChange}
496501
onTextInput={this._onTextInput}
497502
onSelectionChangeShouldSetResponder={emptyFunction.thatReturnsTrue}
503+
onLayout={this.props.onLayout}
498504
placeholder={this.props.placeholder}
499505
placeholderTextColor={this.props.placeholderTextColor}
500506
text={this.state.bufferedValue}
@@ -530,6 +536,7 @@ var TextInput = React.createClass({
530536
onChange={this._onChange}
531537
onEndEditing={this.props.onEndEditing}
532538
onSubmitEditing={this.props.onSubmitEditing}
539+
onLayout={this.props.onLayout}
533540
password={this.props.password || this.props.secureTextEntry}
534541
placeholder={this.props.placeholder}
535542
text={this.state.bufferedValue}

0 commit comments

Comments
 (0)