Commit 2307ea6
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

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


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

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

[IOS] [BUGFIX] [TextInput] - Fix TextInput.clear() and TextInput.setNativeProps({text: ''}) to work
Pull Request resolved: #18278
Reviewed By: shergin
Differential Revision: D9692561
Pulled By: hramos
fbshipit-source-id: b7ce8f6740fdf666e71d6a85743331ca4805edcb
1 parent 9570d7d commit 2307ea6
1 file changed
+15
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
104 | 119 | | |
105 | 120 | | |
106 | 121 | | |
| |||
0 commit comments