Skip to content

TextInput not working as expected when programatically entering text #13112

Description

@ted-ks

The below code does not work properly in iOS (iPhone 6). When I press ‘Push Me’, the word is not displayed completely and the cursor is also not shown. On further investigation, I found out that onChangeText and onContentSize change are not triggered. Pressing any key on the key board after pressing the ‘Push Me’ button displays the full word. I want the full word to be displayed when the button is clicked. It works, if I use value prop to update the TextInput. But I need to display formatted text like in the ‘TokenizedTextExample’ in this link: https://facebook.github.io/react-native/docs/textinput.html

"react-native": "0.41.2"
"react": "15.4.2"

import React, { Component } from 'react';
import {
  AppRegistry,
  TouchableOpacity,
  TextInput,
  Text,
  View
} from 'react-native';

export default class keypost extends Component {
  constructor(props) {
    super(props);
    this.state = {
      part: '',
      update: true
    };
  }


  myfunc() {
    this.setState({ part: <Text><Text style={{ color: 'blue' }}>"thi sgs g _is_good_boyo lllllll COurs uad is sfd_sdf llllsdf sfsddfadfadsfadsff dsafdfas"</Text> <Text>"fasdfa sjsjsjs jsjsjsj sjsjshshshsshshss"</Text></Text> })
  }
  render() {
    var parts = this.state.part
    return (
      <View style={{ paddingTop: 50 }}>
        <TextInput
          multiline={true}
          style={{ height: 300 }}
          >
          <Text>{parts}</Text>
        </TextInput>
        <TouchableOpacity style={{ height: 100, width: 100 }} onPress={this.myfunc.bind(this)} >
          <Text style={{}}>
            Push Me
            </Text>
        </TouchableOpacity>
      </View>
    );
  }

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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