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

Fix setting keyboardType from breaking autoCapitalize #27523

Closed
wants to merge 6 commits into from
Closed
Changes from 4 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 @@ -67,6 +67,9 @@
import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.Map;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;

/** Manages instances of TextInput. */
@ReactModule(name = ReactTextInputManager.REACT_CLASS)
Expand Down Expand Up @@ -103,6 +106,14 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
private static final String KEYBOARD_TYPE_NUMBER_PAD = "number-pad";
private static final String KEYBOARD_TYPE_PHONE_PAD = "phone-pad";
private static final String KEYBOARD_TYPE_VISIBLE_PASSWORD = "visible-password";
private static final List<String> KEYBOARD_TYPES = new ArrayList<>(Arrays.asList(
safaiyeh marked this conversation as resolved.
Show resolved Hide resolved
KEYBOARD_TYPE_EMAIL_ADDRESS,
KEYBOARD_TYPE_NUMERIC,
KEYBOARD_TYPE_DECIMAL_PAD,
KEYBOARD_TYPE_NUMBER_PAD,
KEYBOARD_TYPE_PHONE_PAD,
KEYBOARD_TYPE_VISIBLE_PASSWORD
));
private static final InputFilter[] EMPTY_FILTERS = new InputFilter[0];
private static final int UNSET = -1;

Expand Down Expand Up @@ -717,7 +728,9 @@ public void setAutoCapitalize(ReactEditText view, Dynamic autoCapitalize) {
@ReactProp(name = "keyboardType")
public void setKeyboardType(ReactEditText view, @Nullable String keyboardType) {
int flagsToSet = InputType.TYPE_CLASS_TEXT;
if (KEYBOARD_TYPE_NUMERIC.equalsIgnoreCase(keyboardType)) {
if (keyboardType == null || !KEYBOARD_TYPES.contains(keyboardType)) {
safaiyeh marked this conversation as resolved.
Show resolved Hide resolved
return;
} else if (KEYBOARD_TYPE_NUMERIC.equalsIgnoreCase(keyboardType)) {
flagsToSet = INPUT_TYPE_KEYBOARD_NUMBERED;
} else if (KEYBOARD_TYPE_NUMBER_PAD.equalsIgnoreCase(keyboardType)) {
flagsToSet = INPUT_TYPE_KEYBOARD_NUMBER_PAD;
Expand Down