Skip to content

Commit 28a3425

Browse files
committed
fix(mobile): Keep the last line of iOS markdown replies visible
iOS markdown rows could draw one line short, leaving blank space where the last line of a paragraph belonged. The text view's container followed the view's frame, which pixel rounding can leave a fraction of a point shorter than the text the shadow node measured, and TextKit drops a final line that does not fully fit. Size the container by hand with unbounded height so the view's bounds do the clipping.
1 parent 4ee6bfd commit 28a3425

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎apps/mobile/modules/t3-markdown-text/ios/T3MarkdownText.mm‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,12 @@ - (instancetype)initWithFrame:(CGRect)frame
311311
_textView.editable = false;
312312
_textView.textContainerInset = UIEdgeInsetsZero;
313313
_textView.textContainer.lineFragmentPadding = 0;
314+
// The shadow node already sized this view to fit every line. A container
315+
// that tracks the frame can come out a fraction of a point shorter after
316+
// pixel rounding, and TextKit then drops the last line. Size it by hand
317+
// with unbounded height and let the view's bounds clip.
318+
_textView.textContainer.widthTracksTextView = NO;
319+
_textView.textContainer.heightTracksTextView = NO;
314320
_textView.delegate = self;
315321
// Chat text supports selection and contextual actions, but not drag-and-drop.
316322
_textView.textDragInteraction.enabled = NO;
@@ -477,6 +483,7 @@ - (void)drawRect:(CGRect)rect
477483
}
478484
if (frameChanged) {
479485
_textView.frame = _view.frame;
486+
_textView.textContainer.size = CGSizeMake(CGRectGetWidth(_view.frame), CGFLOAT_MAX);
480487
}
481488

482489
// Text attachments have no native link element. Expose their existing runs

0 commit comments

Comments
 (0)