From 8558b85bf47b0c904a3f2bec719d24b3ee4973c0 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Fri, 23 Oct 2026 06:35:46 -0700 Subject: [PATCH] Derive multiline TextInput state from props (#59218) Summary: Use `TextInputProps::multiline` as the source of truth for multiline checks instead of inferring it from the backed UIKit class. This keeps responder offset and selection restoration logic aligned with the declarative props. Changelog: [Internal] Reviewed By: Abbondanzo Differential Revision: D126285220 --- .../ComponentViews/TextInput/RCTTextInputComponentView.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index 281c5ea88b53..8ee9325bf5a0 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -180,7 +180,8 @@ - (void)reactUpdateResponderOffsetForScrollView:(RCTScrollViewComponentView *)sc } else { // Focus on text selection frame focusRect = selection.rect; - BOOL isMultiline = [_backedTextInputView isKindOfClass:[UITextView class]]; + BOOL isMultiline = _props ? static_cast(*_props).multiline + : [_backedTextInputView isKindOfClass:[UITextView class]]; if (!isMultiline) { focusRect.size.height += kSingleLineKeyboardBottomOffset; } @@ -859,7 +860,8 @@ - (void)_setAttributedString:(NSAttributedString *)attributedString // A single-line input that is not being edited has no cursor to keep: UIKit places one when editing begins. // Restoring it anyway makes UIKit scroll the field editor to it when the text doesn't fit, and the editor keeps // that offset after the text fits again, so text typed later in this view (also after recycling) is drawn too high. - BOOL isMultiline = [_backedTextInputView isKindOfClass:[UITextView class]]; + BOOL isMultiline = _props ? static_cast(*_props).multiline + : [_backedTextInputView isKindOfClass:[UITextView class]]; if (isMultiline || _backedTextInputView.isFirstResponder) { // Updating the UITextView attributedText, for example changing the lineHeight, the color or adding // a new paragraph with \n, causes the cursor to move to the end of the Text and scroll.