From b3e7a62b9f505724f860d42143d8e23e4348a6fe Mon Sep 17 00:00:00 2001 From: Russal Arya Date: Fri, 27 Nov 2026 01:53:16 +1100 Subject: [PATCH] iOS: reload input views when autoCapitalize/autoCorrect/spellCheck change on a focused TextInput On iOS (Fabric), changing autoCapitalize, autoCorrect or spellCheck on a focused TextInput updated the backing view but not the keyboard, which kept its old settings until the input lost and regained focus. Call reloadInputViews when any of them change on the first responder, as is already done for keyboardType and returnKeyType, once per props update when several change together. --- .../TextInput/RCTTextInputComponentView.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 e042d4868a0f..c2b39c8b1f55 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -208,6 +208,8 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & const auto &newTextInputProps = static_cast(*props); // Traits: + BOOL needsReloadInputViews = NO; + if (newTextInputProps.multiline != oldTextInputProps.multiline) { [self _setMultiline:newTextInputProps.multiline]; } @@ -215,11 +217,13 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & if (newTextInputProps.traits.autocapitalizationType != oldTextInputProps.traits.autocapitalizationType) { _backedTextInputView.autocapitalizationType = RCTUITextAutocapitalizationTypeFromAutocapitalizationType(newTextInputProps.traits.autocapitalizationType); + needsReloadInputViews = YES; } if (newTextInputProps.traits.autoCorrect != oldTextInputProps.traits.autoCorrect) { _backedTextInputView.autocorrectionType = RCTUITextAutocorrectionTypeFromOptionalBool(newTextInputProps.traits.autoCorrect); + needsReloadInputViews = YES; } if (newTextInputProps.traits.contextMenuHidden != oldTextInputProps.traits.contextMenuHidden) { @@ -251,6 +255,14 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & if (newTextInputProps.traits.spellCheck != oldTextInputProps.traits.spellCheck) { _backedTextInputView.spellCheckingType = RCTUITextSpellCheckingTypeFromOptionalBool(newTextInputProps.traits.spellCheck); + needsReloadInputViews = YES; + } + + // Without the call to reloadInputViews, a change to the capitalization, autocorrection or spell checking of the + // focused field (the first responder) doesn't reach the keyboard until the field loses and regains focus. One + // reload covers all three when they change together. + if (needsReloadInputViews && _backedTextInputView.isFirstResponder) { + [_backedTextInputView reloadInputViews]; } if (newTextInputProps.traits.caretHidden != oldTextInputProps.traits.caretHidden) {