Skip to content

Commit

Permalink
Fix calling onScroll multiple times with incorrect y-axis offset
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekzaw committed Jan 31, 2024
1 parent 2fa000c commit c82c64c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ios/MarkdownTextInputDecoratorView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ - (void)didMoveToWindow {
} else if ([backedTextInputView isKindOfClass:[RCTUITextView class]]) {
_textView = (RCTUITextView *)backedTextInputView;
[_textView setMarkdownUtils:_markdownUtils];
object_setClass(_textView.layoutManager, [MarkdownLayoutManager class]);
[_textView.layoutManager setValue:_markdownUtils forKey:@"markdownUtils"];
NSLayoutManager *layoutManager = _textView.layoutManager; // switching to TextKit 1 compatibility mode
layoutManager.allowsNonContiguousLayout = NO; // workaround for onScroll issue
object_setClass(layoutManager, [MarkdownLayoutManager class]);
[layoutManager setValue:_markdownUtils forKey:@"markdownUtils"];
} else {
react_native_assert(false && "Cannot enable Markdown for this type of TextInput.");
}
Expand All @@ -87,10 +89,10 @@ - (void)willMoveToWindow:(UIWindow *)newWindow
}
if (_textView != nil) {
[_textView setMarkdownUtils:nil];
if (_textView.layoutManager != nil && [object_getClass(_textView.layoutManager) isEqual:[MarkdownLayoutManager class]]) {
[_textView.layoutManager setValue:nil forKey:@"markdownUtils"];
object_setClass(_textView.layoutManager, [NSLayoutManager class]);
}
// if (_textView.layoutManager != nil && [object_getClass(_textView.layoutManager) isEqual:[MarkdownLayoutManager class]]) {
// [_textView.layoutManager setValue:nil forKey:@"markdownUtils"];
// object_setClass(_textView.layoutManager, [NSLayoutManager class]);
// }
}
}

Expand Down

0 comments on commit c82c64c

Please sign in to comment.