Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Fabric: Add TextInput showSoftInputOnFocus support #45173

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
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.

Expand Down Expand Up @@ -692,6 +696,23 @@ - (BOOL)_textOf:(NSAttributedString *)newText equals:(NSAttributedString *)oldTe
}
}

- (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];
}
}

- (SubmitBehavior)getSubmitBehavior
{
const auto &props = static_cast<const TextInputProps &>(*_props);
Expand Down
Loading