Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiline TextInput crash when inserting/removing lots of text #489

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Libraries/Text/TextInput/RCTBaseTextInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ - (void)textInputDidBeginEditing

[_eventDispatcher sendTextEventWithType:RCTTextEventTypeFocus
reactTag:self.reactTag
text:self.backedTextInputView.attributedText.string
text:[self.backedTextInputView.attributedText.string copy] // [TODO(macOS Candidate ISS#2710739)
key:nil
eventCount:_nativeEventCount];
}
Expand All @@ -389,13 +389,13 @@ - (void)textInputDidEndEditing
{
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeEnd
reactTag:self.reactTag
text:self.backedTextInputView.attributedText.string
text:[self.backedTextInputView.attributedText.string copy] // [TODO(macOS Candidate ISS#2710739)
key:nil
eventCount:_nativeEventCount];

[_eventDispatcher sendTextEventWithType:RCTTextEventTypeBlur
reactTag:self.reactTag
text:self.backedTextInputView.attributedText.string
text:[self.backedTextInputView.attributedText.string copy] // [TODO(macOS Candidate ISS#2710739)
key:nil
eventCount:_nativeEventCount];
}
Expand All @@ -412,7 +412,7 @@ - (BOOL)textInputShouldReturn
#endif // ]TODO(macOS Candidate ISS#2710739)
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeSubmit
reactTag:self.reactTag
text:self.backedTextInputView.attributedText.string
text:[self.backedTextInputView.attributedText.string copy] // [TODO(macOS Candidate ISS#2710739)
key:nil
eventCount:_nativeEventCount];
#if TARGET_OS_OSX // [TODO(macOS Candidate ISS#2710739)
Expand Down Expand Up @@ -475,7 +475,7 @@ - (BOOL)textInputShouldChangeTextInRange:(NSRange)range replacementText:(NSStrin
}
}

NSString *previousText = backedTextInputView.attributedText.string ?: @"";
NSString *previousText = [backedTextInputView.attributedText.string copy] ?: @""; // TODO(OSS Candidate ISS#2710739)
tido64 marked this conversation as resolved.
Show resolved Hide resolved

if (range.location + range.length > backedTextInputView.attributedText.string.length) {
_predictedText = backedTextInputView.attributedText.string;
Expand Down Expand Up @@ -522,7 +522,7 @@ - (void)textInputDidChange

if (_onChange) {
_onChange(@{
@"text": self.attributedText.string,
@"text": [self.attributedText.string copy], // [TODO(macOS Candidate ISS#2710739)
@"target": self.reactTag,
@"eventCount": @(_nativeEventCount),
});
Expand Down