react-native/Libraries/Text/TextInput
Mehdi Mulani 892212bad2 Fix controlled <TextInput> on iOS when inputting in Chinese/Japanese
Summary:
@public
This should fix #18403.
When the user is inputting in Chinese/Japanese with <TextInput> in a controlled manner, the RCTBaseTextInputView will compare the JS-generated attributed string against the TextInputView attributed string and repeatedly overwrite the TextInputView one. This is because the native TextInputView will provide extra styling to show that some text is provisional.
My solution is to do a plain text string comparison at this point, like how we do for dictation.

Expected behavior when typing in a language that has "multistage" text input: For instance, in Chinese/Japanese it's common to type out the pronunciation for a word and then choose the appropriate word from above the keyboard. In this model, the "pronunciation" shows up in the text box first and then is replaced with the chosen word.
Using the word Japan which is written 日本 but first typed as にほん. It takes 4 key-presses to get to 日本, since に, ほ, ん, are all typed and then 日本 is selected. So here is what should happen:

1. enter に, onChange fires with 'に', markedTextRange covers 'に'
2. enter ほ, onChange fires with 'にほ', markedTextRange covers 'にほ'
3. enter ん, onChange fires with 'にほん', markedTextRange covers 'にほん'
4. user selects 日本 from the menu above the keyboard (provided by the keyboard/OS), onChange fires with '日本', markedTextRange is removed

previously we were overwriting the attributed text which would remove the markedTextRange, preventing the user from selecting 日本 from above the keyboard.

Cheekily, I've also fixed an issue with secure text entry as it's the same type of problem.

Reviewed By: PeteTheHeat

Differential Revision: D9002295

fbshipit-source-id: 7304ede055f301dab9ce1ea70f65308f2a4b4a8f
2018-07-30 08:01:10 -07:00
..
Multiline Remove some methods that have `NS_UNAVAILABLE` set (#19790) 2018-06-19 02:18:01 -07:00
Singleline Remove some methods that have `NS_UNAVAILABLE` set (#19790) 2018-06-19 02:18:01 -07:00
RCTBackedTextInputDelegate.h Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTBackedTextInputDelegateAdapter.h Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTBackedTextInputDelegateAdapter.m Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTBackedTextInputViewProtocol.h Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTBaseTextInputShadowView.h Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTBaseTextInputShadowView.m Wrong height when TextInput has an empty string 2018-03-19 02:46:34 -07:00
RCTBaseTextInputView.h - Keyboard layout now updates when changing keyboardType while it has focus (#19027) 2018-06-13 22:47:47 -07:00
RCTBaseTextInputView.m Fix controlled <TextInput> on iOS when inputting in Chinese/Japanese 2018-07-30 08:01:10 -07:00
RCTBaseTextInputViewManager.h Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTBaseTextInputViewManager.m - Keyboard layout now updates when changing keyboardType while it has focus (#19027) 2018-06-13 22:47:47 -07:00
RCTInputAccessoryShadowView.h iOS OSS: fixed RNTester - missing RCTInputAccessoryShadowView.* in .xcodeproj 2018-03-17 22:01:15 -07:00
RCTInputAccessoryShadowView.m iOS OSS: fixed RNTester - missing RCTInputAccessoryShadowView.* in .xcodeproj 2018-03-17 22:01:15 -07:00
RCTInputAccessoryView.h Refactor RCTInputAccessoryView view hierarchy and names 2018-03-13 11:25:12 -07:00
RCTInputAccessoryView.m Refactor RCTInputAccessoryView view hierarchy and names 2018-03-13 11:25:12 -07:00
RCTInputAccessoryViewContent.h Refactor RCTInputAccessoryView view hierarchy and names 2018-03-13 11:25:12 -07:00
RCTInputAccessoryViewContent.m Fix bug with <InputAccessoryView> safe area conformance 2018-04-04 16:47:16 -07:00
RCTInputAccessoryViewManager.h Support Input Accessory View (iOS Only) [1/N] 2018-02-27 11:09:30 -08:00
RCTInputAccessoryViewManager.m Replace js Dimensions with shadow view in InputAccessoryViewExample 2018-03-15 10:14:15 -07:00
RCTTextSelection.h Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTTextSelection.m Update license headers for MIT license 2018-02-16 18:31:53 -08:00