-
Notifications
You must be signed in to change notification settings - Fork 24k
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 support for growing multiline TextInput #6552
Comments
Any update on this? Most of the relevant issues have gone quiet |
I posted internally to get some attention, sorry for the wait. |
Summary: This adds proper support for tracking a TextInput content size as discussed in #6552 by adding a new callback that is called every time the content size changes including when first rendering the view. Some points that are up for discussion are what do we want to do with the onChange callback as I don't see any use left for it now that we can track text change in onChangeText and size changes in onContentSizeChange. Also a bit off topic but should we consider renaming onChangeText to onTextChange to keep the naming more consistent (see [this naming justification](https://twitter.com/notbrent/status/709445076850597888)). This is split in 2 commits for easier review, one for iOS and one for android. The iOS implementation simply checks if the content size has changed everytime we update it and fire the callback, the only small issue was that the content size had several different values on initial render so I added a check to not fire events before the layoutSubviews where at this point the value is g Closes #8457 Differential Revision: D3528202 Pulled By: dmmiller fbshipit-source-id: fefe83f10cc5bfde1f5937c48c88b10408e58d9d
Summary: This adds proper support for tracking a TextInput content size as discussed in facebook#6552 by adding a new callback that is called every time the content size changes including when first rendering the view. Some points that are up for discussion are what do we want to do with the onChange callback as I don't see any use left for it now that we can track text change in onChangeText and size changes in onContentSizeChange. Also a bit off topic but should we consider renaming onChangeText to onTextChange to keep the naming more consistent (see [this naming justification](https://twitter.com/notbrent/status/709445076850597888)). This is split in 2 commits for easier review, one for iOS and one for android. The iOS implementation simply checks if the content size has changed everytime we update it and fire the callback, the only small issue was that the content size had several different values on initial render so I added a check to not fire events before the layoutSubviews where at this point the value is g Closes facebook#8457 Differential Revision: D3528202 Pulled By: dmmiller fbshipit-source-id: fefe83f10cc5bfde1f5937c48c88b10408e58d9d
Summary: This adds proper support for tracking a TextInput content size as discussed in facebook#6552 by adding a new callback that is called every time the content size changes including when first rendering the view. Some points that are up for discussion are what do we want to do with the onChange callback as I don't see any use left for it now that we can track text change in onChangeText and size changes in onContentSizeChange. Also a bit off topic but should we consider renaming onChangeText to onTextChange to keep the naming more consistent (see [this naming justification](https://twitter.com/notbrent/status/709445076850597888)). This is split in 2 commits for easier review, one for iOS and one for android. The iOS implementation simply checks if the content size has changed everytime we update it and fire the callback, the only small issue was that the content size had several different values on initial render so I added a check to not fire events before the layoutSubviews where at this point the value is g Closes facebook#8457 Differential Revision: D3528202 Pulled By: dmmiller fbshipit-source-id: fefe83f10cc5bfde1f5937c48c88b10408e58d9d
How is onContentSizeChange getting fired? I'm on Android and react-native v0.32.0, multiline is true. I only get onContentSizeChange fired for the first time, after that it doesn't fire even after i'm hitting the next line. |
Our application has tons of forms that are paused and resumed at a later date, and currently this issue alone is making react-native a headache for us. |
Checking on v0.33 rn on android, multiline is true. |
Issue reported by @jayshah123 and @holyxiaoxin still persists on v0.34. For now I am using both onChange and onContentSizeChange. The former for Android and the latter for iOS. |
Oh ,I get the same issue too as reported by @jayshah123 and @holyxiaoxin |
onContentSizeChange is not working on 0.37 |
is it still on there? |
FWIW |
It's still on there :) |
the issue is in 0.38.1 |
Looks like this is fixed in newer versions of RN |
In Android onContentSizeChange is called only once use onChange instead of onContentSizeChange. (http://stackoverflow.com/questions/41670903/oncontentsizechange-not-firing-on-height-change-on-android-react-native, facebook/react-native#6552 (comment))
In Android onContentSizeChange is called only once use onChange instead of onContentSizeChange. (http://stackoverflow.com/questions/41670903/oncontentsizechange-not-firing-on-height-change-on-android-react-native, facebook/react-native#6552 (comment))
In Android onContentSizeChange is called only once used onChange instead of onContentSizeChange. (http://stackoverflow.com/questions/41670903/oncontentsizechange-not-firing-on-height-change-on-android-react-native, facebook/react-native#6552 (comment))
In Android onContentSizeChange is called only once used onChange instead of onContentSizeChange. (http://stackoverflow.com/questions/41670903/oncontentsizechange-not-firing-on-height-change-on-android-react-native, facebook/react-native#6552 (comment))
In Android onContentSizeChange is called only once used onChange instead of onContentSizeChange. (http://stackoverflow.com/questions/41670903/oncontentsizechange-not-firing-on-height-change-on-android-react-native, facebook/react-native#6552 (comment))
In Android onContentSizeChange is called only once used onChange instead of onContentSizeChange. (http://stackoverflow.com/questions/41670903/oncontentsizechange-not-firing-on-height-change-on-android-react-native, facebook/react-native#6552 (comment)) set default height after sending message.
In Android onContentSizeChange is called only once used onChange instead of onContentSizeChange. (http://stackoverflow.com/questions/41670903/oncontentsizechange-not-firing-on-height-change-on-android-react-native, facebook/react-native#6552 (comment)) set default height after sending message.
In more recent version of RN, the onContentSizeChange is only called with the initial size, and onChange is called thereafter. See facebook/react-native#6552 (comment) 962
In Android onContentSizeChange is called only once used onChange instead of onContentSizeChange. (http://stackoverflow.com/questions/41670903/oncontentsizechange-not-firing-on-height-change-on-android-react-native, facebook/react-native#6552 (comment)) set default height after sending message.
In Android onContentSizeChange is called only once used onChange instead of onContentSizeChange. (http://stackoverflow.com/questions/41670903/oncontentsizechange-not-firing-on-height-change-on-android-react-native, facebook/react-native#6552 (comment)) set default height after sending message.
In Android onContentSizeChange is called only once used onChange instead of onContentSizeChange. (http://stackoverflow.com/questions/41670903/oncontentsizechange-not-firing-on-height-change-on-android-react-native, facebook/react-native#6552 (comment)) set default height after sending message.
Original discussion here: #1229 (comment)
Problem
Potential solutions
onChange
like @deanmcpherson did in iOS Text - Modify "onChange" behaviour to allow for all changes in contentSize #6283onContentSizeChange
event which can be observed independently of onTextChange." ([TextInput - Multiline] Reimplemented RCTTextView and added auto height scaling. #1229 (comment)) -- I did this for Android in this commit.Decision that needs to be made
onContentSizeChange
? (an aside, see our justification for naming).onChange
event from TextInput and just provide it inonContentSizeChange
?@nicklockwood @deanmcpherson @bestander
The text was updated successfully, but these errors were encountered: