-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix onLayout
prop for TextInput on Android
#18040
Conversation
When the `autogrow` prop was removed from `TextInput` on Android, the `_onLayout` helper method was removed. This helper method implemented the hook required to make `autogrow` work, then dispatched the `onLayout` event to the handler in `this.props`. This change points passes the `onLayout` handler from `this.props` directly to the inner component.
@@ -880,7 +880,7 @@ const TextInput = createReactClass({ | |||
|
|||
return ( | |||
<TouchableWithoutFeedback | |||
onLayout={this._onLayout} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do this.props.onLayout to maintain equality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chirag04 - this.props
is copied into a local variable:
https://github.com/facebook/react-native/blob/master/Libraries/Components/TextInput/TextInput.js#L836
This is exactly how it's done for iOS:
https://github.com/facebook/react-native/blob/master/Libraries/Components/TextInput/TextInput.js#L771
https://github.com/facebook/react-native/blob/master/Libraries/Components/TextInput/TextInput.js#L822
Good catch! @facebook-github-bot shipit |
Something went wrong executing that command, @hramos could you take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janicduplessis is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
When the
autogrow
prop was removed fromTextInput
on Android, the_onLayout
helper method was removed. This helper method implemented the hook required to makeautogrow
work, then dispatched theonLayout
event to the handler inthis.props
. This change points passes theonLayout
handler fromthis.props
directly to the inner component.Motivation
I was updating copied code in react-native-windows and noticed this bug.
Test Plan
Run jest tests.
Related PRs
N/A
Release Notes
[ANDROID][MINOR][BUGFIX] [TextInput] - Fix
onLayout
prop for TextInput on Android