Skip to content

Commit

Permalink
Updated TextInput autoCompleteType prop to autoComplete 1/2 (#26010)
Browse files Browse the repository at this point in the history
Summary:
Fix for bug #26003 Rename TextInput prop "autoCompleteType" to "autoComplete".

## Changelog

[Android] [Changed] - Updated `autoCompleteType` prop of `TextInput` to `autoComplete`

Pull Request resolved: #26010

Test Plan:
Test Pass

PR for [Doc Update](facebook/react-native-website#1184)

Reviewed By: mdvacca

Differential Revision: D29980220

Pulled By: lunaleaps

fbshipit-source-id: 3c9e7d3250b5f95b0dbd523fdb0d917a039cd6a9
  • Loading branch information
jeswinsimon authored and facebook-github-bot committed Jul 30, 2021
1 parent feae814 commit 8066bc9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const AndroidTextInputViewConfig = {
multiline: true,
color: {process: require('../../StyleSheet/processColor')},
autoCompleteType: true,
autoComplete: true,
numberOfLines: true,
letterSpacing: true,
returnKeyLabel: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,20 +715,25 @@ public void setMaxLength(ReactEditText view, @Nullable Integer maxLength) {
view.setFilters(newFilters);
}

@ReactProp(name = "autoCompleteType")
public void setTextContentType(ReactEditText view, @Nullable String autoCompleteType) {
if (autoCompleteType == null) {
@ReactProp(name = "autoComplete")
public void setTextContentType(ReactEditText view, @Nullable String autoComplete) {
if (autoComplete == null) {
setImportantForAutofill(view, View.IMPORTANT_FOR_AUTOFILL_NO);
} else if ("off".equals(autoCompleteType)) {
} else if ("off".equals(autoComplete)) {
setImportantForAutofill(view, View.IMPORTANT_FOR_AUTOFILL_NO);
} else if (REACT_PROPS_AUTOFILL_HINTS_MAP.containsKey(autoCompleteType)) {
setAutofillHints(view, REACT_PROPS_AUTOFILL_HINTS_MAP.get(autoCompleteType));
} else if (REACT_PROPS_AUTOFILL_HINTS_MAP.containsKey(autoComplete)) {
setAutofillHints(view, REACT_PROPS_AUTOFILL_HINTS_MAP.get(autoComplete));
} else {
throw new JSApplicationIllegalArgumentException(
"Invalid autoCompleteType: " + autoCompleteType);
throw new JSApplicationIllegalArgumentException("Invalid autoComplete: " + autoComplete);
}
}

// TODO: T96744578 - Delete autoCompleteType prop
@ReactProp(name = "autoCompleteType")
public void setTextContentTypeDeprecated(ReactEditText view, @Nullable String autoCompleteType) {
setTextContentType(view, autoCompleteType);
}

@ReactProp(name = "autoCorrect")
public void setAutoCorrect(ReactEditText view, @Nullable Boolean autoCorrect) {
// clear auto correct flags, set SUGGESTIONS or NO_SUGGESTIONS depending on value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ AndroidTextInputProps::AndroidTextInputProps(
const RawProps &rawProps)
: ViewProps(context, sourceProps, rawProps),
BaseTextProps(context, sourceProps, rawProps),
autoComplete(convertRawProp(
context,
rawProps,
"autoComplete",
sourceProps.autoComplete,
{})),
autoCompleteType(convertRawProp(
context,
rawProps,
Expand Down Expand Up @@ -262,6 +268,7 @@ AndroidTextInputProps::AndroidTextInputProps(
folly::dynamic AndroidTextInputProps::getDynamic() const {
folly::dynamic props = folly::dynamic::object();
props["autoCompleteType"] = autoCompleteType;
props["autoComplete"] = autoComplete;
props["returnKeyLabel"] = returnKeyLabel;
props["numberOfLines"] = numberOfLines;
props["disableFullscreenUI"] = disableFullscreenUI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class AndroidTextInputProps final : public ViewProps, public BaseTextProps {

#pragma mark - Props

const std::string autoComplete{};
const std::string autoCompleteType{};
const std::string returnKeyLabel{};
const int numberOfLines{0};
Expand Down

0 comments on commit 8066bc9

Please sign in to comment.