-
Notifications
You must be signed in to change notification settings - Fork 25k
Description
Is this a bug report?
YES
Have you read the Contributing Guidelines?
YES
Environment
react-native -v:
react-native-cli: 2.0.1
react-native: 0.47.1node -v:
v7.10.1npm -v:
4.2.0yarn --version:
Then, specify:
-
Target Platform:
iOS, Android - Problem only reproducable on Android right now. -
Development Operating System: MacOS 10.12,
-
Build tools: Android Studio 2.3.3
Steps to Reproduce
- Create a new project with create-react-native-app AwesomeProject
- Change the code in App.js to the following (apologies for the styling)
`
import React from 'react';
import { StyleSheet, Text, View, TextInput, Platform } from 'react-native';
export default class App extends React.Component {
constructor(props) {
super(props)
this.state = {
value: '',
height: 20
}
this.onContentSizeChange = this.onContentSizeChange.bind(this)
}
onContentSizeChange(e) {
const contentSize = e.nativeEvent.contentSize
this.setState({height: contentSize.height > 100 ? 100 : contentSize.height})
console.log(this.state.height)
}
render() {
return (
Open up App.js to start working on your app!
Changes you make will automatically reload.
Shake your phone to open the developer menu.
<TextInput
placeholder = 'type your text here'
multiline = {true}
style = {[styles.textInput,{height: this.state.height, width: 200}]}
value = {this.state.text}
onContentSizeChange={(e)=> this.onContentSizeChange(e)}
/>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
paddingTop: 40,
paddingHorizontal: 10
},
textInput: {
marginLeft: 10,
fontSize: 16,
lineHeight: 18,
marginTop: Platform.select({
ios: 6,
android: 0,
}),
marginBottom: Platform.select({
ios: 5,
android: 3,
}),
},
});
`
- Run the app and start typing in the text input box until the whole text input box is filled and keep going. Past that point you can't see what you are typing any more.
- This behaviour happens even if we replace the height with a static value (eg. 100) instead of this.state.height
Expected Behavior
The focus of the text input should remain at the last character input.
Actual Behavior
Focus of the text input is outside the visible area
Reproducible Demo
See the example code listed above.
