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

[Android] [Added] Add showSoftInputOnFocus to TextInput #25028

Closed
Closed
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ type AndroidProps = $ReadOnly<{|
| 'yes'
| 'yesExcludeDescendants'
),
showSoftInputOnFocus?: ?boolean,
|}>;

type Props = $ReadOnly<{|
Expand Down Expand Up @@ -926,6 +927,12 @@ const TextInput = createReactClass({
'newPassword',
'oneTimeCode',
]),
/**
* When `false`, it will prevent the soft keyboard from showing when the field is focused.
* Defaults to `true`.
* @platform android
*/
showSoftInputOnFocus: PropTypes.bool,
},
getDefaultProps() {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
}
setFocusableInTouchMode(true);
boolean focused = super.requestFocus(direction, previouslyFocusedRect);
showSoftKeyboard();
if (getShowSoftInputOnFocus()) {
showSoftKeyboard();
}
return focused;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,12 @@ public void setBorderStyle(ReactEditText view, @Nullable String borderStyle) {
view.setBorderStyle(borderStyle);
}

@ReactProp(name = "showSoftInputOnFocus", defaultBoolean = true)
public void showKeyboardOnFocus(ReactEditText view, boolean showKeyboardOnFocus) {
view.setShowSoftInputOnFocus(showKeyboardOnFocus);
}


@ReactPropGroup(names = {
ViewProps.BORDER_WIDTH,
ViewProps.BORDER_LEFT_WIDTH,
Expand Down