Skip to content

Commit 0f1bddd

Browse files
NoahDorfman00meta-codesync[bot]
authored andcommitted
iOS: reload input views when keyboardType/returnKeyType change on a focused TextInput (Fabric) (#57868)
Summary: On the new architecture, changing `keyboardType` (or `returnKeyType`) on a currently focused `TextInput` has no visible effect: the trait is set on the backing view, but the keyboard does not update until the field loses and regains focus. The legacy architecture handles this correctly — `RCTBaseTextInputView.mm`'s `setKeyboardType:` calls `reloadInputViews` when the field is first responder, with a comment explaining why: ```objc // Without the call to reloadInputViews, the keyboard will not change until the textview field (the first responder) // loses and regains focus. ``` That call was not carried over to Fabric's `RCTTextInputComponentView.mm`, where `updateProps:` only assigns `_backedTextInputView.keyboardType`. This PR restores parity by calling `reloadInputViews` when the field is first responder, for both `keyboardType` and `returnKeyType`. With this fix, apps that switch a focused input between keyboard types (e.g. a chat-style composer that toggles between text and numeric entry) get the same in-place, single-frame keyboard layout swap as the legacy architecture and native UIKit trait updates — instead of having to work around it by remounting the input or swapping focus between duplicate inputs, both of which tear the keyboard down and re-present it. ## Changelog: [IOS] [FIXED] - TextInput: update the keyboard when `keyboardType`/`returnKeyType` change while the input is focused (new architecture parity with the legacy architecture) Pull Request resolved: #57868 Test Plan: In a new-architecture app (RN 0.80, iOS 26 simulator), render a focused `<TextInput>` whose `keyboardType` prop toggles between `default` and `numbers-and-punctuation`: - Before: the keyboard does not change until focus is lost and regained (or, if the input is remounted as a workaround, the keyboard fully dismisses and re-presents). - After: the keyboard layout swaps in place in a single frame while the field stays focused, verified by frame-by-frame inspection of a simulator screen recording; behavior matches the same transition performed in Safari (which updates input traits on a single responder) and matches the legacy architecture. `returnKeyType` changes on a focused field likewise update the return key immediately. Reviewed By: sbuggay Differential Revision: D115352138 Pulled By: fabriziocucci fbshipit-source-id: 1e92edf3e6f592e8a2b10fa5fb8903254cbc280a
1 parent 8415753 commit 0f1bddd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,18 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
258258

259259
if (newTextInputProps.traits.keyboardType != oldTextInputProps.traits.keyboardType) {
260260
_backedTextInputView.keyboardType = RCTUIKeyboardTypeFromKeyboardType(newTextInputProps.traits.keyboardType);
261+
// Without the call to reloadInputViews, the keyboard will not change until the textInput field (the first
262+
// responder) loses and regains focus.
263+
if (_backedTextInputView.isFirstResponder) {
264+
[_backedTextInputView reloadInputViews];
265+
}
261266
}
262267

263268
if (newTextInputProps.traits.returnKeyType != oldTextInputProps.traits.returnKeyType) {
264269
_backedTextInputView.returnKeyType = RCTUIReturnKeyTypeFromReturnKeyType(newTextInputProps.traits.returnKeyType);
270+
if (_backedTextInputView.isFirstResponder) {
271+
[_backedTextInputView reloadInputViews];
272+
}
265273
}
266274

267275
if (newTextInputProps.traits.textContentType != oldTextInputProps.traits.textContentType) {

0 commit comments

Comments
 (0)