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] Implement missing showSoftInputOnFocus prop on TextInput on the new arch #35878

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
[self _setMultiline:newTextInputProps.traits.multiline];
}

if (newTextInputProps.traits.showSoftInputOnFocus != oldTextInputProps.traits.showSoftInputOnFocus) {
[self _setShowSoftInputOnFocus:newTextInputProps.traits.showSoftInputOnFocus];
}

if (newTextInputProps.traits.autocapitalizationType != oldTextInputProps.traits.autocapitalizationType) {
_backedTextInputView.autocapitalizationType =
RCTUITextAutocapitalizationTypeFromAutocapitalizationType(newTextInputProps.traits.autocapitalizationType);
Expand Down Expand Up @@ -596,6 +600,26 @@ - (void)_setMultiline:(BOOL)multiline
RCTCopyBackedTextInput(_backedTextInputView, backedTextInputView);
_backedTextInputView = backedTextInputView;
[self addSubview:_backedTextInputView];

auto const &currentTextInputProps = *std::static_pointer_cast<TextInputProps const>(_props);
[self _setShowSoftInputOnFocus:currentTextInputProps.traits.showSoftInputOnFocus];
}

- (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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ BaseTextInputProps::BaseTextInputProps(
"maxLength",
sourceProps.maxLength,
{})),
showSoftInputOnFocus(convertRawProp(
context,
rawProps,
"showSoftInputOnFocus",
sourceProps.showSoftInputOnFocus,
{})),
text(convertRawProp(context, rawProps, "text", sourceProps.text, {})),
mostRecentEventCount(convertRawProp(
context,
Expand Down Expand Up @@ -173,6 +179,7 @@ void BaseTextInputProps::setProp(
RAW_SET_PROP_SWITCH_CASE_BASIC(cursorColor);
RAW_SET_PROP_SWITCH_CASE_BASIC(text);
RAW_SET_PROP_SWITCH_CASE_BASIC(mostRecentEventCount);
RAW_SET_PROP_SWITCH_CASE_BASIC(showSoftInputOnFocus);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class BaseTextInputProps : public ViewProps, public BaseTextProps {

int maxLength{};

bool showSoftInputOnFocus{false};

/*
* "Private" (only used by TextInput.js) props
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ AndroidTextInputProps::AndroidTextInputProps(
"importantForAutofill",
sourceProps.importantForAutofill,
{})),
showSoftInputOnFocus(CoreFeatures::enablePropIteratorSetter? sourceProps.showSoftInputOnFocus : convertRawProp(context, rawProps,
"showSoftInputOnFocus",
sourceProps.showSoftInputOnFocus,
{false})),
autoCapitalize(CoreFeatures::enablePropIteratorSetter? sourceProps.autoCapitalize : convertRawProp(context, rawProps,
"autoCapitalize",
sourceProps.autoCapitalize,
Expand Down Expand Up @@ -227,7 +223,6 @@ void AndroidTextInputProps::setProp(
RAW_SET_PROP_SWITCH_CASE_BASIC(inlineImageLeft);
RAW_SET_PROP_SWITCH_CASE_BASIC(inlineImagePadding);
RAW_SET_PROP_SWITCH_CASE_BASIC(importantForAutofill);
RAW_SET_PROP_SWITCH_CASE_BASIC(showSoftInputOnFocus);
RAW_SET_PROP_SWITCH_CASE_BASIC(autoCapitalize);
RAW_SET_PROP_SWITCH_CASE_BASIC(autoCorrect);
RAW_SET_PROP_SWITCH_CASE_BASIC(allowFontScaling);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class AndroidTextInputProps final : public BaseTextInputProps {
std::string inlineImageLeft{};
int inlineImagePadding{0};
std::string importantForAutofill{};
bool showSoftInputOnFocus{false};
std::string autoCapitalize{};
bool autoCorrect{false};
bool allowFontScaling{false};
Expand Down