Skip to content

Commit

Permalink
Apply facebook#18456 Fix controlled TextInput for Chinese (and other …
Browse files Browse the repository at this point in the history
…languages)
  • Loading branch information
magicien committed Mar 21, 2018
1 parent d53747f commit 169a025
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Libraries/Text/TextInput/RCTBaseTextInputShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ @implementation RCTBaseTextInputShadowView
NSAttributedString *_Nullable _localAttributedText;
CGSize _previousContentSize;

NSString *_text;
NSTextStorage *_textStorage;
NSTextContainer *_textContainer;
NSLayoutManager *_layoutManager;
Expand Down Expand Up @@ -97,6 +98,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 @@ -311,7 +311,7 @@ - (void)textInputDidChange

_nativeEventCount++;

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

0 comments on commit 169a025

Please sign in to comment.