Commit 606f1d7
committed
fix(ios): center typed text and caret in single-line TextInput when lineHeight > fontSize
UITextField's placeholder path (UILabel-based) honors
NSBaselineOffsetAttributeName, but the UIFieldEditor path that draws
typed text does not. So the Fabric baseline-offset fix centers multi-line
typed text (UITextView respects the offset) but leaves single-line typed
text pinned at the bottom of the paragraphStyle-sized line box.
Override setDefaultTextAttributes: and setAttributedText: on RCTUITextField
to forward a stripped copy of the paragraph style to super when
paragraphStyle.maximumLineHeight > font.lineHeight — minimumLineHeight
and maximumLineHeight are zeroed out. UITextField then renders the text
at its natural font line height and its built-in vertical centering
positions it correctly in the bounds. Also drop
NSBaselineOffsetAttributeName on those ranges: the offset is wasted on
UITextField's typed-text draw path and a non-zero value inflates the
caret rect without moving the glyph.
The local _defaultTextAttributes ivar keeps the original paragraph style
so _placeholderTextAttributes and the caretRectForPosition: override
continue to see the real lineHeight.1 parent acf0eb1 commit 606f1d7
1 file changed
Lines changed: 61 additions & 2 deletions
Lines changed: 61 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | 94 | | |
96 | | - | |
| 95 | + | |
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
100 | 159 | | |
101 | 160 | | |
102 | 161 | | |
| |||
0 commit comments