From b52950bda23b2fe9847c8263003e00d4f8fcc9e7 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 7 Jul 2021 07:09:19 -0700 Subject: [PATCH] Apply correct text attributes in TextInput.setTextAndSelection Summary: Changelog: [internal] Make sure correct text attributes are used inside of view command. Reviewed By: sshic Differential Revision: D29585943 fbshipit-source-id: 4748c843ff586f1dd42f3a89460afb624f9b371a --- .../ComponentViews/TextInput/RCTTextInputComponentView.mm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index b5433539d47..b7a76f07d27 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -421,11 +421,9 @@ using namespace facebook::react; } _comingFromJS = YES; if (![value isEqualToString:_backedTextInputView.attributedText.string]) { - NSMutableAttributedString *mutableString = - [[NSMutableAttributedString alloc] initWithAttributedString:_backedTextInputView.attributedText]; - [mutableString replaceCharactersInRange:NSMakeRange(0, _backedTextInputView.attributedText.length) - withString:value]; - [self _setAttributedString:mutableString]; + NSAttributedString *attributedString = + [[NSAttributedString alloc] initWithString:value attributes:_backedTextInputView.defaultTextAttributes]; + [self _setAttributedString:attributedString]; [self _updateState]; }