From 76eb18c357e438b1c428d2a5551b3d53ef88fffc Mon Sep 17 00:00:00 2001 From: Qichen Zhu <57348009+QichenZhu@users.noreply.github.com> Date: Sat, 1 Jun 2024 23:35:17 +1200 Subject: [PATCH] fix: correct content height in TextKit 1 compatibility mode --- ios/MarkdownTextInputDecoratorView.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ios/MarkdownTextInputDecoratorView.mm b/ios/MarkdownTextInputDecoratorView.mm index eaa8a59b..a77d7d53 100644 --- a/ios/MarkdownTextInputDecoratorView.mm +++ b/ios/MarkdownTextInputDecoratorView.mm @@ -72,6 +72,14 @@ - (void)didMoveToWindow { _textView = (RCTUITextView *)_backedTextInputView; [_textView setMarkdownUtils:_markdownUtils]; NSLayoutManager *layoutManager = _textView.layoutManager; // switching to TextKit 1 compatibility mode + + // Correct content height in TextKit 1 compatibility mode. (See https://github.com/Expensify/App/issues/41567) + // Consider removing this fix if it is no longer needed after migrating to TextKit 2. + CGSize contentSize = _textView.contentSize; + CGRect textBounds = [layoutManager usedRectForTextContainer:_textView.textContainer]; + contentSize.height = textBounds.size.height + _textView.textContainerInset.top + _textView.textContainerInset.bottom; + [_textView setContentSize:contentSize]; + layoutManager.allowsNonContiguousLayout = NO; // workaround for onScroll issue object_setClass(layoutManager, [MarkdownLayoutManager class]); [layoutManager setValue:_markdownUtils forKey:@"markdownUtils"];