question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible bug with TextInput and Chinese input method on iOS

See original GitHub issue

Description

I have some TextInput components in my project and there should be some problems with onEndEditting and onBlur props of TextInput component. If I make the TextInput blur before I confirm the entered content from the Chinese input method, all the changes I made during this round of focus will be lost. Check the video below, starts from 0:17, the video demonstrates the issue.

Basically, it should be an issue between the system Chinese input method and the RN TextInput component. I made a 30-second video record to demonstrate this issue.

https://www.youtube.com/watch?v=BG0WNHW2MEc

repro

repro2

Reproduction

I don’t know how to work with Chinese input methods on rnplay, so I’ve pushed a sample project with minimal code for reproduction.

Current code with a workaround

Original bug reproduction

I created a new project. The only modified file is the index.ios.js

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

export default class ChineseTextInputIssue extends Component {
  constructor (props) {
    super(props);
    this.state = {
      text: ''
    };
  }

  render () {
    return (
      <View style={styles.container}>
        <TextInput
          style={styles.inputField}
          placeholder="Type here to translate!"
          value={this.state.text}
          onBlur={(evt) => console.log('onBlur event:', evt.nativeEvent.text)}
          onChange={(evt) => console.log('onChange event:', evt.nativeEvent.text)}
          onChangeText={(text) => this.setState({ text })}
          onSubmitEditing={(evt) => console.log('onSubmitEditing event:', evt.nativeEvent.text)}
          onEndEditing={(evt) => console.log('onEndEditing event:', evt.nativeEvent.text)} />
        <Text style={styles.previewText}>
          {this.state.text}
        </Text>
        <TextInput style={styles.inputField} placeholder="Another to focus, meaningless" />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF'
  },
  inputField: {
    margin: 30,
    height: 50
  },
  previewText: {
    padding: 10,
    fontSize: 42
  }
});

AppRegistry.registerComponent('ChineseTextInputIssue', () => ChineseTextInputIssue);

Solution

As you can see from the video, the displayed text and the text in the TextInput component should be identical.

Additional Information

  • React Native version: 0.41.2
  • Platform: iOS, not tested on Android
  • Operating System: macOS 10.12.3

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:9
  • Comments:36 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
ankur-sardarcommented, Jun 12, 2018

Any Update on this issue? (exist in 0.55.4)

9reactions
fengzhang-57blockscommented, Apr 8, 2018

problem happened in react-native version 0.55.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Q: Chinese input crash my iPhone 4S (iOS 5.01)
But after that I'm keep experiencing app crash issue when typing Chinese characters by using the internal input method provided by iOS.
Read more >
[#QTBUG-79177] Chinese qml input broken on iOS
Since the last iOS update (iOS 13.1.2), the qml text input don't behave properly when using Chinese input: on the first edit, it...
Read more >
Input field iOS Safari bug — Can't type in any text
It's working as expected on desktop, Android, iOS Chrome, but sometimes in iOS Safari when typing into the box, no text enters, even...
Read more >
[Bug] iOS: CJK IME unable to work continuously when there ...
In IOS application scenario, when Chinese input is used, the text cannot be input normally, and continuous text input cannot be realized.
Read more >
Chinese Keyboard Entry (Mac) - Miami University
Setting Up a Chinese Keyboard in Mac OS. Open the System Preferences Panel by clicking on the Apple Menu in the upper-left-hand corner...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found