Skip to content

Commit

Permalink
Update types for autoComplete prop. (#25549)
Browse files Browse the repository at this point in the history
Summary:
I believe there's a mismatch between the type definitions and the expected prop in Android for `TextInput`'s `autoComplete` prop.

* Android is expecting `autoComplete`.
* JS types are expecting `autoCompleteType`.
* Latest documentation documents `autoCompleteType`.

Prop added here: 179d490

This change updates the JS types to match what Android is expecting (`autoComplete`). Can update documentation if this is the approach we'd prefer (rather than updating Android to expect `autoCompleteType`).

## Changelog

[Javascript] [Fixed] - Update types for `TextInput`'s `autoComplete` prop.
Pull Request resolved: #25549

Test Plan:
Before:

* Pass invalid value to `TextInput`'s `autoComplete` prop, see no type errors on JS side, and Android blows up with:

```sh
Invalid autocomplete option: foobar
updateViewProp
    ViewManagersPropertyCache.java:95
setProperty
    ViewManagerPropertyUpdater.java:132
updateProps
    ViewManagerPropertyUpdater.java:51
updateProperties
    ViewManager.java:37
```

After:

* Pass invalid value to `TextInput`'s `autoComplete` prop, see PropType warning for `autoComplete` prop.

Differential Revision: D16220809

Pulled By: mdvacca

fbshipit-source-id: e25e198cbcbe721c8d71f069bba293856bf5f36d
  • Loading branch information
drtangible authored and facebook-github-bot committed Jul 12, 2019
1 parent afe06e5 commit daa6b0a
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -589,39 +589,39 @@ public void setMaxLength(ReactEditText view, @Nullable Integer maxLength) {
view.setFilters(newFilters);
}

@ReactProp(name = "autoComplete")
public void setTextContentType(ReactEditText view, @Nullable String autocomplete) {
if (autocomplete == null) {
@ReactProp(name = "autoCompleteType")
public void setTextContentType(ReactEditText view, @Nullable String autoCompleteType) {
if (autoCompleteType == null) {
setImportantForAutofill(view, View.IMPORTANT_FOR_AUTOFILL_NO);
} else if ("username".equals(autocomplete)) {
} else if ("username".equals(autoCompleteType)) {
setAutofillHints(view, View.AUTOFILL_HINT_USERNAME);
} else if ("password".equals(autocomplete)) {
} else if ("password".equals(autoCompleteType)) {
setAutofillHints(view, View.AUTOFILL_HINT_PASSWORD);
} else if ("email".equals(autocomplete)) {
} else if ("email".equals(autoCompleteType)) {
setAutofillHints(view, View.AUTOFILL_HINT_EMAIL_ADDRESS);
} else if ("name".equals(autocomplete)) {
} else if ("name".equals(autoCompleteType)) {
setAutofillHints(view, View.AUTOFILL_HINT_NAME);
} else if ("tel".equals(autocomplete)) {
} else if ("tel".equals(autoCompleteType)) {
setAutofillHints(view, View.AUTOFILL_HINT_PHONE);
} else if ("street-address".equals(autocomplete)) {
} else if ("street-address".equals(autoCompleteType)) {
setAutofillHints(view, View.AUTOFILL_HINT_POSTAL_ADDRESS);
} else if ("postal-code".equals(autocomplete)) {
} else if ("postal-code".equals(autoCompleteType)) {
setAutofillHints(view, View.AUTOFILL_HINT_POSTAL_CODE);
} else if ("cc-number".equals(autocomplete)) {
} else if ("cc-number".equals(autoCompleteType)) {
setAutofillHints(view, View.AUTOFILL_HINT_CREDIT_CARD_NUMBER);
} else if ("cc-csc".equals(autocomplete)) {
} else if ("cc-csc".equals(autoCompleteType)) {
setAutofillHints(view, View.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE);
} else if ("cc-exp".equals(autocomplete)) {
} else if ("cc-exp".equals(autoCompleteType)) {
setAutofillHints(view, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE);
} else if ("cc-exp-month".equals(autocomplete)) {
} else if ("cc-exp-month".equals(autoCompleteType)) {
setAutofillHints(view, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH);
} else if ("cc-exp-year".equals(autocomplete)) {
} else if ("cc-exp-year".equals(autoCompleteType)) {
setAutofillHints(view, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR);
} else if ("off".equals(autocomplete)) {
} else if ("off".equals(autoCompleteType)) {
setImportantForAutofill(view, View.IMPORTANT_FOR_AUTOFILL_NO);
} else {
throw new JSApplicationIllegalArgumentException(
"Invalid autocomplete option: " + autocomplete);
"Invalid autoCompleteType: " + autoCompleteType);
}
}

Expand Down

0 comments on commit daa6b0a

Please sign in to comment.