Commit f864b61
committed
fix(ios): center TextInput text when lineHeight > fontSize on Fabric
Summary:
Ports the Paper-only fix from facebook#38359 to the Fabric (new arch) path.
When `lineHeight` is set larger than the font's intrinsic line height,
UIKit anchors glyphs to the bottom of the attributed-string line box,
making typed text visually sit too low while the placeholder (which
uses a different rendering path) stays correctly centered.
The `RCTApplyBaselineOffset` helper that Paper's fix relies on already
ships in Fabric (`RCTAttributedTextUtils.mm`) and is invoked for
`<Text>` rendering in `RCTTextLayoutManager`, but was never wired into
the `<TextInput>` path. This calls it inside
`RCTTextInputComponentView._setAttributedString:`.
This regression against Paper is tracked in facebook#39145. It has been
reported repeatedly for the new architecture (see comments referring
back to facebook#38359).
Changelog:
[IOS] [FIXED] - Center typed TextInput text when lineHeight > fontSize
on the new architecture.
Test Plan:
Added an RN Tester example ("Single-line lineHeight baseline" under
TextInput examples) that renders a single-line TextInput at a range
of lineHeight values with a fixed fontSize. Before this change,
typing into any of these inputs shows text bottom-anchored inside
the line box while the placeholder is centered. After this change,
typed text centers alongside the placeholder.
Related: facebook#38359, facebook#391451 parent 6530092 commit f864b61
4 files changed
Lines changed: 42 additions & 8 deletions
File tree
- packages
- react-native
- ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager
- React/Fabric/Mounting/ComponentViews/TextInput
- rn-tester/js/examples/TextInput
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
575 | 575 | | |
576 | 576 | | |
577 | 577 | | |
578 | | - | |
579 | | - | |
| 578 | + | |
| 579 | + | |
580 | 580 | | |
581 | 581 | | |
582 | 582 | | |
| |||
766 | 766 | | |
767 | 767 | | |
768 | 768 | | |
769 | | - | |
| 769 | + | |
770 | 770 | | |
| 771 | + | |
| 772 | + | |
771 | 773 | | |
772 | 774 | | |
773 | 775 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
408 | | - | |
| 408 | + | |
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
| 431 | + | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
437 | | - | |
| 437 | + | |
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1188 | 1188 | | |
1189 | 1189 | | |
1190 | 1190 | | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
1191 | 1223 | | |
1192 | 1224 | | |
1193 | 1225 | | |
| |||
0 commit comments