Repository navigation
Commit 3d55ca9
authored
Accept a numeric fontWeight in the Android TextInput native code
## Summary:
On Android, `TextInput` keeps `fontWeight` as a string. So `TextInput.js` changes a numeric `fontWeight` (for example `700`) to a string before it sends the props. The commit that added this ([15f27bc](15f27bc299a)) calls it "a quick and dirty replication" of the `Text.js` logic, to fix later for Fabric.
This PR makes the native code accept a number too:
- **C++** (`AndroidTextInputProps`): a number becomes a string, in the classic parser and in the iterator setter.
- **Kotlin** (`ReactTextInputManager.setFontWeight`): the setter takes a `Dynamic`, so the raw props path also accepts a number. This changes the public signature from `String?` to `Dynamic`.
The JS conversion stays, so a new JS bundle still works with an older native build. A follow-up PR removes it after this change ships.
This also makes a numeric `fontWeight` work in a conditional style value ([RFC](react-native-community/discussions-and-proposals#1010), #60124), because the JS conversion cannot see inside one.
## Changelog:
[ANDROID] [CHANGED] - `TextInput` accepts a numeric `fontWeight` in native code.
## Test Plan:
- New Kotlin test: `ReactTextInputPropertyTest.testFontWeightAcceptsANumber`.
- RNTester on the Android emulator, with the JS conversion removed locally so the number reaches native: a `TextInput` with a numeric `fontWeight` renders with no errors in each combination of the props flags (Props 1.5, Props 2.0, exclusive props updates, the C++ iterator setter).
- `./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests ReactTextInputPropertyTest`: pass.
Differential Revision: D133209822
Pull Request resolved: #601361 parent 3113e81 commit 3d55ca9
4 files changed
Lines changed: 49 additions & 5 deletions
File tree
- packages/react-native
- ReactAndroid
- api
- src
- main/java/com/facebook/react/views/textinput
- test/java/com/facebook/react/views/textinput
- ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6365 | 6365 | | |
6366 | 6366 | | |
6367 | 6367 | | |
6368 | | - | |
| 6368 | + | |
6369 | 6369 | | |
6370 | 6370 | | |
6371 | 6371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
246 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
247 | 255 | | |
248 | 256 | | |
249 | 257 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
563 | 576 | | |
564 | 577 | | |
565 | 578 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
36 | 52 | | |
37 | 53 | | |
38 | 54 | | |
| |||
149 | 165 | | |
150 | 166 | | |
151 | 167 | | |
152 | | - | |
| 168 | + | |
153 | 169 | | |
154 | 170 | | |
155 | 171 | | |
| |||
225 | 241 | | |
226 | 242 | | |
227 | 243 | | |
228 | | - | |
229 | 244 | | |
230 | 245 | | |
231 | 246 | | |
232 | 247 | | |
233 | 248 | | |
234 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
235 | 258 | | |
236 | 259 | | |
237 | 260 | | |
| |||
0 commit comments