From 9cdc19a93669b37c0518bd32263e156ffc9193c7 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 4 May 2020 00:26:50 -0700 Subject: [PATCH] Fixes TextInput shaking when typing Chinese (#28805) Summary: Fixes https://github.com/facebook/react-native/issues/28488. ## Changelog [iOS] [Fixed] - Fixes TextInput shaking when typing Chinese Pull Request resolved: https://github.com/facebook/react-native/pull/28805 Test Plan: Demo see https://github.com/facebook/react-native/issues/28488. Differential Revision: D21376803 Pulled By: shergin fbshipit-source-id: b1fe6cc5f67d42ef98a6c12b8ab9990feac0e2a7 --- Libraries/Text/TextInput/Multiline/RCTUITextView.m | 4 ++++ Libraries/Text/TextInput/Singleline/RCTUITextField.m | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Libraries/Text/TextInput/Multiline/RCTUITextView.m b/Libraries/Text/TextInput/Multiline/RCTUITextView.m index 11f3ec291ad..88d3183f4df 100644 --- a/Libraries/Text/TextInput/Multiline/RCTUITextView.m +++ b/Libraries/Text/TextInput/Multiline/RCTUITextView.m @@ -104,6 +104,10 @@ static UIColor *defaultPlaceholderColor() - (void)setDefaultTextAttributes:(NSDictionary *)defaultTextAttributes { + if ([_defaultTextAttributes isEqualToDictionary:defaultTextAttributes]) { + return; + } + _defaultTextAttributes = defaultTextAttributes; self.typingAttributes = defaultTextAttributes; [self _updatePlaceholder]; diff --git a/Libraries/Text/TextInput/Singleline/RCTUITextField.m b/Libraries/Text/TextInput/Singleline/RCTUITextField.m index de8f6efe844..1dae92a3096 100644 --- a/Libraries/Text/TextInput/Singleline/RCTUITextField.m +++ b/Libraries/Text/TextInput/Singleline/RCTUITextField.m @@ -68,6 +68,10 @@ - (void)setDefaultTextAttributes:(NSDictionary *)defaultTextAttributes { + if ([_defaultTextAttributes isEqualToDictionary:defaultTextAttributes]) { + return; + } + _defaultTextAttributes = defaultTextAttributes; [super setDefaultTextAttributes:defaultTextAttributes]; [self _updatePlaceholder];