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 51914b7448e..8e7cc58c43a 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -191,6 +191,10 @@ static NSSet *returnKeyTypesSet; RCTUITextSmartInsertDeleteTypeFromOptionalBool(newTextInputProps.traits.smartInsertDelete); } + if (newTextInputProps.traits.showSoftInputOnFocus != oldTextInputProps.traits.showSoftInputOnFocus) { + [self _setShowSoftInputOnFocus:newTextInputProps.traits.showSoftInputOnFocus]; + } + // Traits `blurOnSubmit`, `clearTextOnFocus`, and `selectTextOnFocus` were omitted intentionally here // because they are being checked on-demand. @@ -658,6 +662,23 @@ static NSSet *returnKeyTypesSet; [self addSubview:_backedTextInputView]; } +- (void)_setShowSoftInputOnFocus:(BOOL)showSoftInputOnFocus +{ + if (showSoftInputOnFocus) { + // Resets to default keyboard. + _backedTextInputView.inputView = nil; + + // Without the call to reloadInputViews, the keyboard will not change until the textInput field (the first + // responder) loses and regains focus. + if (_backedTextInputView.isFirstResponder) { + [_backedTextInputView reloadInputViews]; + } + } else { + // Hides keyboard, but keeps blinking cursor. + _backedTextInputView.inputView = [UIView new]; + } +} + - (BOOL)_textOf:(NSAttributedString *)newText equals:(NSAttributedString *)oldText { // When the dictation is running we can't update the attributed text on the backed up text view