react-native-macos/Libraries/Text
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
..
BaseText iOS: Add a maxFontSizeMultiplier prop to <Text> and <TextInput> (#20915) 2018-09-04 17:50:42 -07:00
RCTText.xcodeproj Update Xcode projects (#19574) 2018-06-19 23:48:12 -07:00
RawText Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Text iOS: Add a maxFontSizeMultiplier prop to <Text> and <TextInput> (#20915) 2018-09-04 17:50:42 -07:00
TextInput Fix #18272 TextInput.setNativeProps({text: ''}) to work (#18278) 2018-09-10 17:49:27 -07:00
VirtualText Update license headers for MIT license 2018-02-16 18:31:53 -08:00
RCTConvert+Text.h iOS: fix up RNTesterPods 2018-05-16 14:14:41 -07:00
RCTConvert+Text.m iOS textTransform style support 2018-04-16 09:01:38 -07:00
RCTTextAttributes.h iOS: Add a maxFontSizeMultiplier prop to <Text> and <TextInput> (#20915) 2018-09-04 17:50:42 -07:00
RCTTextAttributes.m iOS: Add a maxFontSizeMultiplier prop to <Text> and <TextInput> (#20915) 2018-09-04 17:50:42 -07:00
RCTTextTransform.h iOS textTransform style support 2018-04-16 09:01:38 -07:00
Text.js JS: Switch to `nullthrows` Package [1/4] 2018-09-10 01:46:48 -07:00
TextAncestor.js Flow strictify possible files in RN core 2018-06-20 00:47:21 -07:00
TextPropTypes.js iOS: Add a maxFontSizeMultiplier prop to <Text> and <TextInput> (#20915) 2018-09-04 17:50:42 -07:00
TextProps.js Add onTextLayout to TextProps 2018-08-30 09:33:05 -07:00
TextStylePropTypes.js Android textTransform style support (#20572) 2018-08-13 21:31:57 -07:00