Skip to content

Commit b10711b

Browse files
committed
[fix] TextInput autoComplete behavior
Fix 'autoComplete' behavior now that Chrome has fixed broken behavior for 'off'. Add fallback support for React Native's 'autoCompleteType' prop. Close #1404
1 parent 5334a4f commit b10711b

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

packages/react-native-web/src/exports/TextInput/__tests__/index-test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ describe('components/TextInput', () => {
2525

2626
test('value "off"', () => {
2727
const input = findNativeInput(shallow(<TextInput autoComplete="off" />));
28-
expect(input.prop('autoComplete')).toEqual('noop');
28+
expect(input.prop('autoComplete')).toEqual('off');
29+
});
30+
31+
test('autoCompleteType fallback', () => {
32+
const input = findNativeInput(shallow(<TextInput autoCompleteType="off" />));
33+
expect(input.prop('autoComplete')).toEqual('off');
2934
});
3035
});
3136

packages/react-native-web/src/exports/TextInput/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ class TextInput extends React.Component<TextInputProps> {
9595
render() {
9696
const {
9797
autoCapitalize = 'sentences',
98-
autoComplete = 'on',
98+
autoComplete,
99+
autoCompleteType,
99100
autoCorrect = true,
100101
autoFocus,
101102
defaultValue,
@@ -144,9 +145,7 @@ class TextInput extends React.Component<TextInputProps> {
144145

145146
Object.assign(supportedProps, {
146147
autoCapitalize,
147-
// Browser's treat autocomplete "off" as "on"
148-
// https://bugs.chromium.org/p/chromium/issues/detail?id=468153#c164
149-
autoComplete: autoComplete === 'off' ? 'noop' : autoComplete,
148+
autoComplete: autoComplete || autoCompleteType || 'on',
150149
autoCorrect: autoCorrect ? 'on' : 'off',
151150
autoFocus,
152151
classList: [classes.textinput],

packages/react-native-web/src/exports/TextInput/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type TextInputProps = {
2121
...ViewProps,
2222
autoCapitalize?: 'characters' | 'none' | 'sentences' | 'words',
2323
autoComplete?: string,
24+
autoCompleteType?: string, // Compat with React Native (Bug react-native#26003)
2425
autoCorrect?: boolean,
2526
autoFocus?: boolean,
2627
blurOnSubmit?: boolean,

0 commit comments

Comments
 (0)