diff --git a/RNTester/js/TextInputExample.android.js b/RNTester/js/TextInputExample.android.js index 83a4ac124..35208c6cb 100644 --- a/RNTester/js/TextInputExample.android.js +++ b/RNTester/js/TextInputExample.android.js @@ -49,6 +49,9 @@ class TextEventsExample extends React.Component { onChange={(event) => this.updateText( 'onChange text: ' + event.nativeEvent.text )} + onContentSizeChange={(event) => this.updateText( + 'onContentSizeChange size: ' + event.nativeEvent.contentSize + )} onEndEditing={(event) => this.updateText( 'onEndEditing text: ' + event.nativeEvent.text )} @@ -71,7 +74,6 @@ class AutoExpandingTextInput extends React.Component { constructor(props) { super(props); this.state = { - text: 'React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about — learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native.', height: 0, }; } @@ -83,11 +85,7 @@ class AutoExpandingTextInput extends React.Component { onContentSizeChange={(event) => { this.setState({height: event.nativeEvent.contentSize.height}); }} - onChangeText={(text) => { - this.setState({text}); - }} - style={[styles.default, {height: Math.max(35, this.state.height)}]} - value={this.state.text} + style={[styles.default, {height: Math.min(200, Math.max(35, this.state.height))}]} /> ); } @@ -619,6 +617,7 @@ exports.examples = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index 1665bba19..bf318a0dc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -629,6 +629,10 @@ public class ReactEditText extends EditText { listener.onTextChanged(s, start, before, count); } } + + if (mContentSizeWatcher != null) { + mContentSizeWatcher.onLayout(); + } } @Override