React-native: TextInput broken for Korean in ReactNative 0.54 and 0.55

Created on 17 May 2018  ยท  11Comments  ยท  Source: facebook/react-native

Environment

Environment:
OS: macOS High Sierra 10.13.4
Node: 6.11.0
Yarn: Not Found
npm: 3.10.10
Watchman: Not Found
Xcode: Xcode 9.3 Build version 9E145
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: ^16.3.1 => 16.3.1
react-native: ^0.55.4 => 0.55.4

Steps to Reproduce

In TextInput, just type some Korean characters, such as "์˜คํ›„์˜ ํ™์ฐจ". Then move the cursor to the space between "์˜คํ›„์˜" and "ํ™์ฐจ", and then type some more Korean characters, such as "๋ง›์žˆ๋Š”"

Expected Behavior

The text should be input like "์˜คํ›„์˜ ๋ง›์žˆ๋Š” ํ™์ฐจ"

Actual Behavior

However, as of RN version 0.54 and 0.55, the text is input like "์˜คํ›„์˜ ใ…ใ…ใ…‡ใ…ฃใ…†ใ„ดใ…กใ„ด ํ™์ฐจ"

Specifically, Korean characters are combined correctly when the cursor is at the end of text in TextInput, but if the cursor is placed at any position other than the end, Korean characters are not combined correctly.

TextInput Stale

Most helpful comment

This is the very critical issue for Korean user.

All 11 comments

@shergin Do you mind looking at this issue? I've looked through the refactored codes for TextInput module in RN 0.54.0 and found that _onChange event in RCTBaseTextInputView.textInputDidChange breaks Korean IM input status.

This causes Korean characters to be typed like "ใ…‡ใ…ใ„ดใ„ดใ…•ใ…‡" instead of "์•ˆ๋…•". (Each part of character is input separately. They should be combined to form a complete character.)

Maybe i'm wrong, but looks similar to this issue:

18456

I have the same problem with japanese, i'm not able to write kanjis.

@rodolphefauquez It is a related issue. However, PR #18456 doesn't solve the Hangul input issue.

@shergin I did some more experimentation with this issue. It seems that the problem does not to lie with new TextInput implementation but rather with React Native's setState() call + view re-rendering cycle. (I guess the implementation behind this has changed in RN 0.54.0 as well.)

If I delete onChange/onChangeText callback from tag in jsx file, Hangul input issue disappears. But I do need onChange callback. If someone who is more familiar with RN 0.54 update details can suggest where this issue might be stemming from, it would be very much appreciated.

This is the very critical issue for Korean user.

This might cure it. It might happen when typing Japanese Hanja, Chinese. But, so far I have not confronted when I type Korean. Weird. I'm Korean, so I use it very much.

https://github.com/facebook/react-native/pull/18456#issuecomment-388171810

The quick fix is not to setState in onChangeText and rather set this to private variable inside component which won't affect the render system. The default TextInput will show the output of the text when typing.

example

private searchTxt: string = '';
...
<TextInput
    onChangeText={(text) => this.searchTxt = text;}
    underlineColorAndroid='transparent' // android fix
    multiline={false}
    style={styles.inputSearch}
    onSubmitEditing={this.onSearch}
    defaultValue={this.searchTxt}
/>

Note: Above is just the workaround in ios. In android it won't work because text in TextInput is always changed when setState.

Think this might be caused by the same root problem discussed in #18874. Please check out their discussions.

still happens in RN 0.57

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

Was this page helpful?
0 / 5 - 0 ratings