From 81d5d46660606f6ab4114f53aeb228a2793ed14d Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Wed, 20 Dec 2017 15:45:00 +0100 Subject: [PATCH] fix autoComplete for demo --- less/control.less | 40 +++++++++++++--------------------------- scss/control.scss | 39 +++++++++++++-------------------------- src/Select.js | 4 ++-- 3 files changed, 28 insertions(+), 55 deletions(-) diff --git a/less/control.less b/less/control.less index eb42708329..fbeb60b5b2 100644 --- a/less/control.less +++ b/less/control.less @@ -27,6 +27,19 @@ .Select { position: relative; + input:-webkit-autofill { + // Expose a hook for JavaScript when autofill is shown + // JavaScript can capture 'animationstart' events + // @see https://medium.com/@brunn/detecting-autofilled-fields-in-javascript-aed598d25da7 + animation-name: onAutoFillStart; + } + + input:not(:-webkit-autofill) { + // Expose a hook for JS onAutoFillCancel + // JavaScript can capture 'animationstart' events + animation-name: onAutoFillCancel; + } + // disable some browser-specific behaviours that break the input input::-webkit-contacts-auto-fill-button, input::-webkit-credentials-auto-fill-button { @@ -219,19 +232,6 @@ padding: ((@select-input-internal-height - 14) / 2 - 2) 0 ((@select-input-internal-height - 14) / 2 + 2); /* For IE 8 compatibility */ -webkit-appearance: none; - &:-webkit-autofill { - // Expose a hook for JavaScript when autofill is shown - // JavaScript can capture 'animationstart' events - // @see https://medium.com/@brunn/detecting-autofilled-fields-in-javascript-aed598d25da7 - animation-name: onAutoFillStart; - } - - &:not(:-webkit-autofill) { - // Expose a hook for JS onAutoFillCancel - // JavaScript can capture 'animationstart' events - animation-name: onAutoFillCancel; - } - .is-focused & { cursor: text; } @@ -346,20 +346,6 @@ padding: 0; position: absolute; width: 1px; - - - &:-webkit-autofill { - // Expose a hook for JavaScript when autofill is shown - // JavaScript can capture 'animationstart' events - // @see https://medium.com/@brunn/detecting-autofilled-fields-in-javascript-aed598d25da7 - animation-name: onAutoFillStart; - } - - &:not(:-webkit-autofill) { - // Expose a hook for JS onAutoFillCancel - // JavaScript can capture 'animationstart' events - animation-name: onAutoFillCancel; - } } // Animation diff --git a/scss/control.scss b/scss/control.scss index a3f0771ef8..0ea707c2c9 100644 --- a/scss/control.scss +++ b/scss/control.scss @@ -12,6 +12,19 @@ .Select { position: relative; + input:-webkit-autofill { + // Expose a hook for JavaScript when autofill is shown + // JavaScript can capture 'animationstart' events + // @see https://medium.com/@brunn/detecting-autofilled-fields-in-javascript-aed598d25da7 + animation-name: onAutoFillStart; + } + + input:not(:-webkit-autofill) { + // Expose a hook for JS onAutoFillCancel + // JavaScript can capture 'animationstart' events + animation-name: onAutoFillCancel; + } + // disable some browser-specific behaviours that break the input input::-webkit-contacts-auto-fill-button, input::-webkit-credentials-auto-fill-button { @@ -205,19 +218,6 @@ padding: (($select-input-internal-height - 14) / 2 - 2) 0 (($select-input-internal-height - 14) / 2 + 2); /* For IE 8 compatibility */ -webkit-appearance: none; - &:-webkit-autofill { - // Expose a hook for JavaScript when autofill is shown - // JavaScript can capture 'animationstart' events - // @see https://medium.com/@brunn/detecting-autofilled-fields-in-javascript-aed598d25da7 - animation-name: onAutoFillStart; - } - - &:not(:-webkit-autofill) { - // Expose a hook for JS onAutoFillCancel - // JavaScript can capture 'animationstart' events - animation-name: onAutoFillCancel; - } - .is-focused & { cursor: text; } @@ -323,19 +323,6 @@ padding: 0; position: absolute; width: 1px; - - &:-webkit-autofill { - // Expose a hook for JavaScript when autofill is shown - // JavaScript can capture 'animationstart' events - // @see https://medium.com/@brunn/detecting-autofilled-fields-in-javascript-aed598d25da7 - animation-name: onAutoFillStart; - } - - &:not(:-webkit-autofill) { - // Expose a hook for JS onAutoFillCancel - // JavaScript can capture 'animationstart' events - animation-name: onAutoFillCancel; - } } // Animation diff --git a/src/Select.js b/src/Select.js index 7d1ec060b3..298548aad2 100644 --- a/src/Select.js +++ b/src/Select.js @@ -95,7 +95,7 @@ class Select extends React.Component { if (this.props.autoFocus || this.props.autofocus) { this.focus(); } - if (!this.props.multi) { + if (this.isAutoCompleteEnabled()) { this.addAutoFillListener(); } } @@ -864,7 +864,7 @@ class Select extends React.Component { const inputProps = { ...this.props.inputProps, role: 'combobox', - autoComplete: useAutoComplete ? this.props.autoComplete : 'off', + autoComplete: useAutoComplete ? this.props.autoComplete : null, 'aria-expanded': '' + isOpen, 'aria-owns': ariaOwns, 'aria-haspopup': '' + isOpen,