From 1fce89176b2b87ea1914f94cf036b06a3176c4c1 Mon Sep 17 00:00:00 2001 From: Ben Nham Date: Mon, 6 Jun 2016 12:54:37 -0700 Subject: [PATCH] Explicitly set default background color in RCTTextView Summary: RCTShadowText currently explicitly defaults to black text color: https://github.com/facebook/react-native/blob/d46ac11/Libraries/Text/RCTShadowText.m#L204 However, the UITextView used by RCTTextInput doesn't explicitly default to black text color. This causes issues when RCTTextInput is in rich text editing mode (i.e. when the element uses child nodes to provide extra styling info) and the client doesn't provide us with any explicit color info. In this case, the following series of badness occurs: 1. -[UITextView attributedText] will return an attributed string without the NSColor property set. 2. -[RCTShadowText attributedString] will return an attributed string with NSColor equal to blackColor. 3. The `[_textView.attributedText isEqualToAttributedString:_pendingAttributedText]` check in -performPendingTextUpdate will fail and causes -[UITextView setText:] to be called. 4. -setText: clears the marked text range in the text view, which breaks multi-character autocomplete (e.g. QWERTY input methods for CJK languages). The easiest fix for now is to just make sure RCTUITextView and RCTShadowText default to the same text color. Reviewed By: nicklockwood Differential Revision: D3368726 fbshipit-source-id: a92cb188c60bac80d963af6b1f2a09f27ae084f5 --- Libraries/Text/RCTTextView.m | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/Text/RCTTextView.m b/Libraries/Text/RCTTextView.m index 2d4c0a7d9..9b0a4d737 100644 --- a/Libraries/Text/RCTTextView.m +++ b/Libraries/Text/RCTTextView.m @@ -86,6 +86,7 @@ _textView = [[RCTUITextView alloc] initWithFrame:CGRectZero]; _textView.backgroundColor = [UIColor clearColor]; + _textView.textColor = [UIColor blackColor]; _textView.scrollsToTop = NO; _textView.scrollEnabled = NO; _textView.delegate = self;