react-native/Libraries
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
..
ART RN: Move ART Canvas Workaround 2018-07-19 19:02:13 -07:00
ActionSheetIOS Update Xcode projects (#19574) 2018-06-19 23:48:12 -07:00
Alert Prettier React Native Libraries 2018-05-10 19:10:38 -07:00
Animated Add FlatList and SectionList to Animated exports 2018-07-17 22:35:28 -07:00
AppState Prettier React Native Libraries 2018-05-10 19:10:38 -07:00
BatchedBridge Eliminate circular dependency between MessageQueue and JSTimers modules. (#19526) 2018-06-15 17:06:29 -07:00
Blob Flow strictify possible files in RN core 2018-06-20 00:47:21 -07:00
BugReporting Flow strictify possible files in RN core 2018-06-20 00:47:21 -07:00
CameraRoll Fix crash in RCTImagePicker on iOS 2018-07-12 10:33:01 -07:00
Color Bump Prettier to 1.13.4 on xplat 2018-06-06 05:32:06 -07:00
Components Adding flow strict to as many xplat files as possible 2018-07-27 12:31:42 -07:00
Core Eliminate circular dependency between MessageQueue and JSTimers modules. (#19526) 2018-06-15 17:06:29 -07:00
EventEmitter Prettier React Native Libraries 2018-05-10 19:10:38 -07:00
Experimental Adding custom view to swipeable component 2018-06-21 10:33:07 -07:00
Geolocation Update Xcode projects (#19574) 2018-06-19 23:48:12 -07:00
Image Adding flow strict to as many xplat files as possible 2018-07-27 12:31:42 -07:00
Inspector RN: Fix Element Inspector w/ Start + End Styles 2018-06-26 13:33:43 -07:00
Interaction RN: Remove ReactPerf References 2018-05-15 13:16:57 -07:00
JSInspector Prettier React Native Libraries 2018-05-10 19:10:38 -07:00
LayoutAnimation Remove @providesModule from all modules 2018-04-25 07:37:10 -07:00
Linking Prettier React Native Libraries 2018-05-10 19:10:38 -07:00
LinkingIOS Update Xcode projects (#19574) 2018-06-19 23:48:12 -07:00
Lists VirtualizedList: Fix spacer size calculation (#18105) 2018-07-20 00:17:05 -07:00
Modal Switch to Platform.isTV to pass Android Flow 2018-06-10 13:45:57 -07:00
NativeAnimation Update Xcode projects (#19574) 2018-06-19 23:48:12 -07:00
Network Adding flow strict to as many xplat files as possible 2018-07-27 12:31:42 -07:00
Performance Flow strictify possible files in RN core 2018-06-20 00:47:21 -07:00
PermissionsAndroid Prettier React Native Libraries 2018-05-10 19:10:38 -07:00
PushNotificationIOS Update Xcode projects (#19574) 2018-06-19 23:48:12 -07:00
RCTTest Update Xcode projects (#19574) 2018-06-19 23:48:12 -07:00
ReactNative Flow strictify possible files in RN core 2018-06-20 00:47:21 -07:00
Renderer React sync for revisions ca0941f...bc1ea9c 2018-07-25 16:17:51 -07:00
Sample Adding flow strict to as many xplat files as possible 2018-07-27 12:31:42 -07:00
Settings Adding flow strict to as many xplat files as possible 2018-07-27 12:31:42 -07:00
Share Prettier React Native Libraries 2018-05-10 19:10:38 -07:00
Storage Prettier React Native Libraries 2018-05-10 19:10:38 -07:00
StyleSheet RN: Refine `StyleSheet.compose` Flow Type 2018-07-17 18:03:00 -07:00
SurfaceBackedComponent Update license headers for MIT license 2018-02-16 18:31:53 -08:00
SurfaceHostingComponent Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Text Fix controlled <TextInput> on iOS when inputting in Chinese/Japanese 2018-07-30 08:01:10 -07:00
Types Flow strictify possible files in RN core 2018-06-20 00:47:21 -07:00
Utilities Adding flow strict to as many xplat files as possible 2018-07-27 12:31:42 -07:00
Vibration Update Xcode projects (#19574) 2018-06-19 23:48:12 -07:00
WebSocket - Correct fishhook import in RCTReconnectingWebSocket Fixes #16039 (#16271) 2018-06-28 11:49:32 -07:00
Wrapper Update additional license headers 2018-03-08 12:10:14 -08:00
YellowBox YellowBox: Fix Off-By-1 Content Rendering Bug 2018-06-26 13:33:42 -07:00
fishhook Merge fishhook.xcodeproj in RCTWebSocket 2017-08-09 07:48:09 -07:00
polyfills fix missing prettier file (#20001) 2018-07-02 10:48:06 -07:00
react-native Flow strictify possible files in RN core 2018-06-20 00:47:21 -07:00
vendor Upgrade Prettier to 1.13.6 on fbsource 2018-06-27 03:32:42 -07:00
.npmignore npmignore: ignore tests and fixtures 2018-02-27 08:42:14 -08:00
Promise.js Prettier React Native Libraries 2018-05-10 19:10:38 -07:00
UTFSequence.js RN: A wild YellowBox has appeared! 2018-06-11 18:31:18 -07:00
promiseRejectionIsError.js Prettier React Native Libraries 2018-05-10 19:10:38 -07:00