From f462fc15fedfb69f40c3d765312b32fcbc78e4bd Mon Sep 17 00:00:00 2001 From: jamiel rahi <36601220+jamfromouterspace@users.noreply.github.com> Date: Sat, 5 Sep 2026 23:22:33 +0200 Subject: [PATCH] Preserve TextInput returnKeyType when changing multiline RCTCopyBackedTextInput copies the keyboard traits over to the replacement backing view when a TextInput switches between single-line and multiline, but omits returnKeyType. The prop itself is unchanged across the transition, so the prop diff does not re-run the setter and the new view keeps its default Return key. Copy returnKeyType alongside keyboardType, and add a regression test next to the existing tintColor one. --- .../ComponentViews/TextInput/RCTTextInputUtils.mm | 1 + .../React/Tests/Text/RCTTextInputUtilsTest.mm | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm index ea70105798ab..2ee9dd67e67c 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm @@ -43,6 +43,7 @@ void RCTCopyBackedTextInput( toTextInput.scrollEnabled = fromTextInput.scrollEnabled; toTextInput.secureTextEntry = fromTextInput.secureTextEntry; toTextInput.keyboardType = fromTextInput.keyboardType; + toTextInput.returnKeyType = fromTextInput.returnKeyType; toTextInput.textContentType = fromTextInput.textContentType; toTextInput.smartInsertDeleteType = fromTextInput.smartInsertDeleteType; toTextInput.passwordRules = fromTextInput.passwordRules; diff --git a/packages/react-native/React/Tests/Text/RCTTextInputUtilsTest.mm b/packages/react-native/React/Tests/Text/RCTTextInputUtilsTest.mm index 2559670f8658..0adb9424c4af 100644 --- a/packages/react-native/React/Tests/Text/RCTTextInputUtilsTest.mm +++ b/packages/react-native/React/Tests/Text/RCTTextInputUtilsTest.mm @@ -26,4 +26,15 @@ - (void)testCopyBackedTextInputPreservesTintColor XCTAssertEqualObjects(destination.tintColor, UIColor.redColor); } +- (void)testCopyBackedTextInputPreservesReturnKeyType +{ + RCTUITextField *source = [RCTUITextField new]; + RCTUITextView *destination = [RCTUITextView new]; + source.returnKeyType = UIReturnKeyDone; + + RCTCopyBackedTextInput(source, destination); + + XCTAssertEqual(destination.returnKeyType, UIReturnKeyDone); +} + @end