react-native/Libraries/Text/TextInput
magicien 2307ea60d0 Fix #18272 TextInput.setNativeProps({text: ''}) to work (#18278)
Summary:
Fix #18272. Calling textInputRef.setNativeProps({text: ''}) or textInputRef.clear() should clear the text input.

- All tests of `yarn run test` are passed
- Test with [the sample app](https://github.com/magicien/react-native-textinput-clear).
    - TextInput.clear() and TextInput.setNativeProps({ text: '***' }) worked
    - When clear() or setNativeProps() called, onChange/onChangeText wasn't called
        - Same behavior as react 0.53.0
    - When non-string values are given to `setNativeProps({text: ___})`, its behavior is the same as react 0.53.0.
        - Value Type | Result
          ---------- | ------------
          null       | same as empty string ''
          undefined  | nothing changes
          number     | throw error
          function   | throw error
          object     | throw error
    - When clear() or setNativeProps() called, attributed text keeps the attributes
    - When `value` prop is set, the text can't be changed

- `clear()` doesn't work from the second time
- `setNativeProps({text '***'})` doesn't work from the second time
- Even when `value` prop is set, you can change the text

![ScreenShot_0.54.0](https://raw.githubusercontent.com/magicien/react-native-textinput-clear/master/screenshot/0.54.0_test.gif)

- `clear()` works every time
- `setNativeProps({text '****'})` works every time

![ScreenShot_Clear_1](https://raw.githubusercontent.com/magicien/react-native-textinput-clear/master/screenshot/clear_test_1.gif)

![ScreenShot_Clear_2](https://raw.githubusercontent.com/magicien/react-native-textinput-clear/master/screenshot/clear_test_2.gif)

- The text keeps the attributes (font family, size, color, text align)

![ScreenShot_Slider](https://raw.githubusercontent.com/magicien/react-native-textinput-clear/master/screenshot/attributed_text_test.gif)

- If `value` prop is set, the text should not be changed

![ScreenShot_Value](https://raw.githubusercontent.com/magicien/react-native-textinput-clear/master/screenshot/value_test.gif)

[IOS] [BUGFIX] [TextInput] - Fix TextInput.clear() and TextInput.setNativeProps({text: ''}) to work
Pull Request resolved: https://github.com/facebook/react-native/pull/18278

Reviewed By: shergin

Differential Revision: D9692561

Pulled By: hramos

fbshipit-source-id: b7ce8f6740fdf666e71d6a85743331ca4805edcb
2018-09-10 17:49:27 -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 Fix #18272 TextInput.setNativeProps({text: ''}) to work (#18278) 2018-09-10 17:49:27 -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 Exposed scrollEnabled on TextInput (#19330) 2018-08-08 18:46:53 -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