Skip to content

TextInput box with Limited height doesn't focus to end of line after input exceeds height (RN 47.1, 45.1) #15778

@gavin-gmlab

Description

@gavin-gmlab

Is this a bug report?

YES

Have you read the Contributing Guidelines?

YES

Environment

  1. react-native -v:
    react-native-cli: 2.0.1
    react-native: 0.47.1
  2. node -v:
    v7.10.1
  3. npm -v:
    4.2.0
  4. yarn --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

  1. Create a new project with create-react-native-app AwesomeProject
  2. 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,
}),
},
});
`

  1. 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.
  2. 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

screen shot 2017-09-04 at 11 05 14 am

Reproducible Demo

See the example code listed above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions