Skip to content

Commit

Permalink
fix: correct content height in TextKit 1 compatibility mode
Browse files Browse the repository at this point in the history
  • Loading branch information
QichenZhu committed Jun 1, 2024
1 parent 6541a6e commit 76eb18c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ios/MarkdownTextInputDecoratorView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down

0 comments on commit 76eb18c

Please sign in to comment.