-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
onContentSizeChange in textinput not getting height when text height changes. #11692
Comments
Getting same issue, but only on Android. Event is fired on mount, but isn't fired on text height change. Identical code works fine for iOS: <TextInput |
onChange={(event) => { this worked for me |
instead of onContentSizeChange |
Closing this issue because it has been inactive for a while. If you think it should still be opened let us know why. |
Actually, I am working on this right now. I hope is will fix very soon. |
Summary: Previously <TextInput>'s onContentSizeChange event fires very rearly, usually just once after initial layout. This diff fixed that. I also considered to a bunch of another things to get the native notification, but I found that overriding `onTextChanged` is the most reliable, easy and effitient way to implement this. I tried/considered: * onLayout (does not fire) * OnPreDrawListener (fires to often) * OnGlobalLayoutListener (does not fire) * OnLayoutChangeListener (does not fire) * isLayoutRequested (too hacky) (I also fixed the <AutoExpandingTextInput> demo to illustrate the fix.) And just heads up, we will remove `contentSize` info from `onChange` event very soon. GH issue: #11692 Reviewed By: achen1 Differential Revision: D5132589 fbshipit-source-id: e7edbd8dc5ae891a6f4a87b51d9450b8c6ce4a1e
Fixed! 3539352 |
@shergin is this patched into a release version? |
Summary: Previously <TextInput>'s onContentSizeChange event fires very rearly, usually just once after initial layout. This diff fixed that. I also considered to a bunch of another things to get the native notification, but I found that overriding `onTextChanged` is the most reliable, easy and effitient way to implement this. I tried/considered: * onLayout (does not fire) * OnPreDrawListener (fires to often) * OnGlobalLayoutListener (does not fire) * OnLayoutChangeListener (does not fire) * isLayoutRequested (too hacky) (I also fixed the <AutoExpandingTextInput> demo to illustrate the fix.) And just heads up, we will remove `contentSize` info from `onChange` event very soon. GH issue: facebook/react-native#11692 Reviewed By: achen1 Differential Revision: D5132589 fbshipit-source-id: e7edbd8dc5ae891a6f4a87b51d9450b8c6ce4a1e
using react native 0.46.4 on android, I can't get |
@ramsestom That's expected behaviour. You have to use |
EDIT: actually |
@ramsestom Yes, it was breaking change. (But this feature was never documented.) And I made it... for goods. We had really good reasons for that. Sorry for the inconvenience! Could you please create separate issue discussing inconsistent behaviour of |
Not sure if this has been moved to another issue yet, didn't see one anywhere... @shergin |
@eli-isbell-h360 Interesting, could you please create a snack? |
@shergin Yessir, here it is: https://snack.expo.io/SJB1E3uOb It looks like |
@eli-isbell-h360 Besides this I will investigate this issue. |
@shergin Thanks for working on this! |
<TextInput
multiline={true}
onContentSizeChange={(event) => {
this.setState({height: event.nativeEvent.contentSize.height});
}}
onChangeText={(value) => {
this.setState({value});
}}
style={[{height: 40,borderWidth: 0.5,borderColor: '#0f0f0f',fontSize: 13,padding: 4,width:width-40}, {height: Math.max(40, this.state.height)}]}
defaultValue={this.state.value}
/>
The text was updated successfully, but these errors were encountered: