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

[iOS][TextInput] Fix controlled TextInput for Chinese (and other languages) #18456

Closed
Closed
Show file tree
Hide file tree
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: 12 additions & 0 deletions Libraries/Text/TextInput/RCTBaseTextInputShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ @implementation RCTBaseTextInputShadowView
NSAttributedString *_Nullable _localAttributedText;
CGSize _previousContentSize;

NSString *_text;
NSTextStorage *_textStorage;
NSTextContainer *_textContainer;
NSLayoutManager *_layoutManager;
Expand Down Expand Up @@ -101,6 +102,17 @@ - (void)invalidateContentSize
});
}

- (NSString *)text
{
return _text;
}

- (void)setText:(NSString *)text
{
_text = text;
_previousAttributedText = _localAttributedText;
}

#pragma mark - RCTUIManagerObserver

- (void)uiManagerWillPerformMounting
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Text/TextInput/RCTBaseTextInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ - (void)textInputDidChange

_nativeEventCount++;

if (_onChange) {
if (_onChange && backedTextInputView.markedTextRange == nil) {
_onChange(@{
@"text": self.attributedText.string,
@"target": self.reactTag,
Expand Down