mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Preserve TextInput selection color when changing multiline (#57748)
Summary: - Preserve the native text input tint color when switching between single-line and multiline backing views. - Add a native regression test for copying the tint from `RCTUITextField` to `RCTUITextView`. Fabric replaces the backing text input view when `multiline` changes. `RCTCopyBackedTextInput` preserved the other native presentation properties but omitted `tintColor`, which implements `selectionColor` on iOS. Since the React prop itself was unchanged, the normal prop diff did not apply it again and the selection color fell back to the system tint. Fixes https://github.com/react/react-native/issues/57105 ## Changelog: [IOS] [FIXED] - Preserve TextInput selection color when changing multiline. Pull Request resolved: https://github.com/react/react-native/pull/57748 Test Plan: - Added `RCTTextInputUtilsTest.testCopyBackedTextInputPreservesTintColor`. - Ran clang-format validation and `git diff --check`. Reviewed By: javache Differential Revision: D113980213 Pulled By: Abbondanzo fbshipit-source-id: 73a5f87e1b45b504f4640572b8c1a26b4d97f43f
This commit is contained in:
1 parent
adde1e5888
commit
56c284e152
2 files changed
+30
No files matched your search
+1
@@ -25,6 +25,7 @@ void RCTCopyBackedTextInput(
|
||||
toTextInput.attributedText = RCTSanitizeAttributedString(fromTextInput.attributedText);
|
||||
toTextInput.placeholder = fromTextInput.placeholder;
|
||||
toTextInput.placeholderColor = fromTextInput.placeholderColor;
|
||||
toTextInput.tintColor = fromTextInput.tintColor;
|
||||
toTextInput.textContainerInset = fromTextInput.textContainerInset;
|
||||
toTextInput.inputAccessoryView = fromTextInput.inputAccessoryView;
|
||||
toTextInput.textInputDelegate = fromTextInput.textInputDelegate;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <React/RCTTextInputUtils.h>
|
||||
#import <React/RCTUITextField.h>
|
||||
#import <React/RCTUITextView.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
@interface RCTTextInputUtilsTest : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation RCTTextInputUtilsTest
|
||||
|
||||
- (void)testCopyBackedTextInputPreservesTintColor
|
||||
{
|
||||
RCTUITextField *source = [RCTUITextField new];
|
||||
RCTUITextView *destination = [RCTUITextView new];
|
||||
source.tintColor = UIColor.redColor;
|
||||
|
||||
RCTCopyBackedTextInput(source, destination);
|
||||
|
||||
XCTAssertEqualObjects(destination.tintColor, UIColor.redColor);
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user