iOS: reload input views when keyboardType/returnKeyType change on a focused TextInput (Fabric) - #57868
Conversation
…a focused TextInput The legacy architecture reloads the focused field's input views when its keyboardType changes (RCTBaseTextInputView), so the keyboard updates immediately. The Fabric component sets the trait but never reloads, so the keyboard does not change until the field loses and regains focus. Restore parity by calling reloadInputViews when the field is first responder, for both keyboardType and returnKeyType.
|
Hi @NoahDorfman00! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary
On the new architecture, changing
keyboardType(orreturnKeyType) on a currently focusedTextInputhas 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'ssetKeyboardType:callsreloadInputViewswhen the field is first responder, with a comment explaining why:That call was not carried over to Fabric's
RCTTextInputComponentView.mm, whereupdateProps:only assigns_backedTextInputView.keyboardType. This PR restores parity by callingreloadInputViewswhen the field is first responder, for bothkeyboardTypeandreturnKeyType.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/returnKeyTypechange while the input is focused (new architecture parity with the legacy architecture)Test Plan
In a new-architecture app (RN 0.80, iOS 26 simulator), render a focused
<TextInput>whosekeyboardTypeprop toggles betweendefaultandnumbers-and-punctuation:returnKeyTypechanges on a focused field likewise update the return key immediately.