[fix] TextInput autoComplete="off"

Browsers treat autoComplete "off" as "on". The fix is to provide the browser
with an unrecognized value so that it doesn't attempt to auto-fill the input.

Fix #1249
This commit is contained in:
Nicolas Gallagher
2019-03-07 10:58:27 -08:00
parent 34427897f3
commit e4c3a21c42
2 changed files with 5 additions and 1 deletions
@@ -25,7 +25,7 @@ describe('components/TextInput', () => {
test('value "off"', () => {
const input = findNativeInput(shallow(<TextInput autoComplete="off" />));
expect(input.prop('autoComplete')).toEqual('off');
expect(input.prop('autoComplete')).toEqual('noop');
});
});
@@ -171,6 +171,7 @@ class TextInput extends Component<*> {
render() {
const {
autoComplete,
autoCorrect,
editable,
keyboardType,
@@ -253,6 +254,9 @@ class TextInput extends Component<*> {
const component = multiline ? 'textarea' : 'input';
Object.assign(otherProps, {
// Browser's treat autocomplete "off" as "on"
// https://bugs.chromium.org/p/chromium/issues/detail?id=468153#c164
autoComplete: autoComplete === 'off' ? 'noop' : autoComplete,
autoCorrect: autoCorrect ? 'on' : 'off',
dir: 'auto',
onBlur: normalizeEventHandler(this._handleBlur),