Repository navigation
Conversation
The multiline field sized its TextEditor from an invisible Text copy of the typed text. Text and UITextView lay out a custom font's lines at different heights, so the max-lines cap was never a whole number of the editor's lines. Past the cap the editor scrolls the caret line to the bottom of the frame, and the top line showed cut part way through. The editor is now sized from the UITextView behind it: its content height, in whole lines of its typing font's line height, between min-lines and max-lines. Its text container insets are set to zero on the text view itself instead of being pulled back with negative padding, so no part of a scrolled-off line is drawn outside the field. The field's height now follows its text a moment later than before, so when a focused field gets shorter (a smaller text size, say) it scrolls the caret's line back into view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On iOS, a multiline text input that has gone past its
max-linesshows its top line cut part way through. It's easiest to see with a custom font, and it gets worse at bigger text sizes. We hit it in the devnull app (Geist font) while building its composer and reply bar (NativePHP/dev-null-app#177, #180).Cause
The multiline branch of
NativeUITextInputCoresized itsTextEditorfrom an invisibleTextcopy of the typed text, withlineLimit(min...max).TextandUITextViewlay out a custom font's lines at different heights. With Geist, five lines ofTextcame to about 5.4 lines of the editor. Once the text is longer than that, the editor scrolls the caret line to the bottom of the frame and the top line shows half cut.The editor also used negative padding (-5 / -8) to pull back
UITextView's text container insets, so it drew past its own frame. That's why even the system font field onmainshows a sliver of a sixth line under the fifth.Fix
UITextViewbehind it. A smallUIViewRepresentablein the editor's background finds the text view, watches itscontentSize, and reports its content height and line height. The field is then as tall as its text, in whole lines of the text view's own line height, betweenmin-linesandmax-lines. Past that it scrolls.Android was already fine and isn't touched.
Screenshots
iOS 27.0, iPhone 18 Pro simulator. Each pair is
mainon the left and this branch on the right. The top field uses Geist withmax-lines="5"and the caret at the end; the second uses the system font.Medium text size:
Large (default):
Extra extra large:
Testing
tests/IosMultilineTextInputSizingTest.phpchecks the field is sized from the text view and its insets are zeroed; both tests fail onmain.BaseTextInputSelectionTestmatched the old indentation of theTextEditorline exactly, so that one assertion is now a regex.swiftc -typecheck -wmoover mobile-airmain'sNativeRenderplus this repo'sresources/ios: the same 78 errors asmain(types that live outside those folders) and none in this file. Planted errors in the new code were reported, so the file was checked.main:min-lines="2": its height went 41.67, 62.67, 83.33 pt for 2, 3 and 4 lines (Geist's line is 20.83 pt), and the first line stayed in view as it grew;Not tested: iPad, a hardware keyboard, and iOS 18 or 26 runtimes.
What to watch for
UITextViewunder its own centre. If a future SwiftUI stops backingTextEditorwith aUITextView, nothing is found and the field stays atmin-linesof an estimated line (textSize * 1.3) and scrolls. It wouldn't crash, but it wouldn't grow either.leading-*still has no effect on the typed text, as before. The sizer reads the paragraph style's line spacing in case it ever does.🤖 Generated with Claude Code