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

Add inputType textNoSuggestions in react-native to disable the autocomplete #35691

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
2 changes: 1 addition & 1 deletion Libraries/Components/TextInput/TextInput.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type KeyboardTypeIOS =
| 'name-phone-pad'
| 'twitter'
| 'web-search';
export type KeyboardTypeAndroid = 'visible-password';
export type KeyboardTypeAndroid = 'no-suggestions' | 'visible-password';
export type KeyboardTypeOptions =
| KeyboardType
| KeyboardTypeAndroid
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/TextInput/TextInput.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export type KeyboardType =
// iOS 10+ only
| 'ascii-capable-number-pad'
// Android-only
| 'no-suggestions'
| 'visible-password';

export type InputMode =
Expand Down
2 changes: 2 additions & 0 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export type KeyboardType =
// iOS 10+ only
| 'ascii-capable-number-pad'
// Android-only
| 'no-suggestions'
| 'visible-password';

export type InputMode =
Expand Down Expand Up @@ -677,6 +678,7 @@ export type Props = $ReadOnly<{|
*
* The following values work on Android only:
*
* - `no-suggestions`
* - `visible-password`
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
private static final String KEYBOARD_TYPE_PHONE_PAD = "phone-pad";
private static final String KEYBOARD_TYPE_VISIBLE_PASSWORD = "visible-password";
private static final String KEYBOARD_TYPE_URI = "url";
private static final String KEYBOARD_TYPE_NO_SUGGESTIONS = "no-suggestions";
private static final InputFilter[] EMPTY_FILTERS = new InputFilter[0];
private static final int UNSET = -1;
private static final String[] DRAWABLE_FIELDS = {
Expand Down Expand Up @@ -874,6 +875,8 @@ public void setKeyboardType(ReactEditText view, @Nullable String keyboardType) {
flagsToSet = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
} else if (KEYBOARD_TYPE_URI.equalsIgnoreCase(keyboardType)) {
flagsToSet = InputType.TYPE_TEXT_VARIATION_URI;
} else if (KEYBOARD_TYPE_NO_SUGGESTIONS.equalsIgnoreCase(keyboardType)) {
flagsToSet = InputType.TYPE_TEXT_VARIATION_FILTER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
}

updateStagedInputTypeFlag(view, InputType.TYPE_MASK_CLASS, flagsToSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ module.exports = ([
render: function (): React.Node {
return (
<TextInput
keyboardType={'numeric'}
autoFocus={true}
style={styles.default}
accessibilityLabel="I am the accessibility label for text input"
Expand Down Expand Up @@ -633,13 +634,15 @@ module.exports = ([
<View>
<WithLabel label="none">
<TextInput
keyboardType="no-suggestions"
testID="capitalize-none"
autoCapitalize="none"
style={styles.default}
/>
</WithLabel>
<WithLabel label="sentences">
<TextInput
keyboardType="numeric"
testID="capitalize-sentences"
autoCapitalize="sentences"
style={styles.default}
Expand Down