Repository navigation
Commit d2d61eb
Align TextInput props diffing with native defaults (#59679)
Summary:
Pull Request resolved: #59679
With props diffing, a prop whose value equals its C++ default is not sent when the view is created, so the C++ default has to match the state of a newly created native view. Several `AndroidTextInputProps` fields did not:
- `showSoftInputOnFocus` and `allowFontScaling` defaulted to `false` in C++ but are `true` natively, so setting them to `false` from JS had no effect.
- `autoCorrect` was a plain `bool` defaulting to `false`, while the native setter has three states (on, off, unset). `autoCorrect={false}` was never sent and removing the prop could not restore the platform default. It is now `std::optional<bool>` and is sent as `null` when unset.
- `numberOfLines`, `textBreakStrategy` and `includeFontPadding` were each emitted twice, once from the paragraph attributes and once from a duplicate flat field, with the later one overwriting the earlier. The flat `includeFontPadding` defaulted to `false` while the native default is `true`, so removing `includeFontPadding={true}` sent `false`. These keys are now only emitted from the paragraph attributes.
The flat fields are not used for layout, which reads the paragraph and text attributes, so only the props sent to the native view change.
Changelog:
[Android][Fixed] - Fix `TextInput` props `showSoftInputOnFocus`, `allowFontScaling`, `autoCorrect` and `includeFontPadding` being ignored or reset incorrectly when props diffing is enabled
Differential Revision: D1285947801 parent 6e8b239 commit d2d61eb
3 files changed
Lines changed: 51 additions & 20 deletions
File tree
- packages/react-native/ReactCommon/react/renderer/components/textinput
- platform/android/react/renderer/components/androidtextinput
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
| 294 | + | |
294 | 295 | | |
295 | 296 | | |
296 | 297 | | |
| |||
500 | 501 | | |
501 | 502 | | |
502 | 503 | | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | 504 | | |
508 | 505 | | |
509 | 506 | | |
510 | 507 | | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | 508 | | |
516 | 509 | | |
517 | 510 | | |
| |||
529 | 522 | | |
530 | 523 | | |
531 | 524 | | |
532 | | - | |
| 525 | + | |
| 526 | + | |
533 | 527 | | |
534 | 528 | | |
535 | 529 | | |
| |||
608 | 602 | | |
609 | 603 | | |
610 | 604 | | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | 605 | | |
616 | 606 | | |
617 | 607 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | | - | |
87 | | - | |
88 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
23 | 63 | | |
24 | 64 | | |
25 | 65 | | |
0 commit comments