From c53f54218a4427ce97cf5ad0a40dfb267b00d1b5 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 22 Jun 2018 11:28:37 -0400 Subject: [PATCH] fix controlled textinput for languages and allows clearing to work: https://github.com/facebook/react-native/pull/18456 --- .../Text/TextInput/RCTBaseTextInputShadowView.m | 12 ++++++++++++ Libraries/Text/TextInput/RCTBaseTextInputView.m | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Libraries/Text/TextInput/RCTBaseTextInputShadowView.m b/Libraries/Text/TextInput/RCTBaseTextInputShadowView.m index f5a7ca1724754d..257f3af3e07c2a 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputShadowView.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputShadowView.m @@ -23,6 +23,7 @@ @implementation RCTBaseTextInputShadowView NSAttributedString *_Nullable _localAttributedText; CGSize _previousContentSize; + NSString * _text; NSTextStorage *_textStorage; NSTextContainer *_textContainer; NSLayoutManager *_layoutManager; @@ -101,6 +102,17 @@ - (void)invalidateContentSize }); } +- (NSString *)text +{ + return _text; +} + +- (void)setText:(NSString *)text +{ + _text = text; + _previousAttributedText = _localAttributedText; +} + #pragma mark - RCTUIManagerObserver - (void)uiManagerWillPerformMounting diff --git a/Libraries/Text/TextInput/RCTBaseTextInputView.m b/Libraries/Text/TextInput/RCTBaseTextInputView.m index d3ad1cf633c421..52c164450cab37 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -337,7 +337,7 @@ - (void)textInputDidChange _nativeEventCount++; - if (_onChange) { + if (_onChange && backedTextInputView.markedTextRange == nil) { _onChange(@{ @"text": self.attributedText.string, @"target": self.reactTag,