Commit f218b6f
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 f218b6f
2 files changed
Lines changed: 49 additions & 0 deletions
File tree
- packages
- react-native/React/Fabric/Mounting/ComponentViews/TextInput
- rn-tester/js/examples/TextInput
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
768 | 768 | | |
769 | 769 | | |
770 | 770 | | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
771 | 788 | | |
772 | 789 | | |
773 | 790 | | |
| |||
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