Repository: uber-web/baseui
Pull request #1078 (2019-03-22 23:04:02)

feat(input): adds autocomplete prop
#### Scope

- [x] Minor: New Feature



Patch:
diff --git a/src/input/base-input.js b/src/input/base-input.js
index cd83fc0e5..eaced7033 100644
--- a/src/input/base-input.js
+++ b/src/input/base-input.js
@@ -29,6 +29,7 @@ class BaseInput<T: EventTarget> extends React.Component<
     'aria-labelledby': null,
     'aria-describedby': null,
     adjoined: ADJOINED.none,
+    autoComplete: 'on',
     autoFocus: false,
     disabled: false,
     error: false,
@@ -70,6 +71,7 @@ class BaseInput<T: EventTarget> extends React.Component<
 
   getInputProps = () => {
     const {
+      autoComplete,
       disabled,
       error,
       id,
@@ -94,6 +96,7 @@ class BaseInput<T: EventTarget> extends React.Component<
       'aria-describedby': this.props['aria-describedby'],
       'aria-invalid': !!error,
       'aria-required': required,
+      autoComplete,
       disabled,
       id,
       name,
diff --git a/src/input/input.js b/src/input/input.js
index 270827ff9..4d15a897a 100644
--- a/src/input/input.js
+++ b/src/input/input.js
@@ -18,6 +18,7 @@ import {ADJOINED, ENHANCER_POSITION} from './constants.js';
 
 class Input extends React.Component<InputPropsT, InternalStateT> {
   static defaultProps = {
+    autoComplete: 'on',
     autoFocus: false,
     disabled: false,
     name: '',
diff --git a/src/input/types.js b/src/input/types.js
index 82f5b14e0..8384d8dd5 100644
--- a/src/input/types.js
+++ b/src/input/types.js
@@ -72,6 +72,8 @@ export type BaseInputPropsT<T> = {
   'aria-describedby': ?string,
   /** Defines styles for inputs that are grouped with other controls. */
   adjoined: AdjoinedT,
+  /** Determines if browser should provide value suggestions. */
+  autoComplete: string,
   /** If true the input will be focused on the first mount. */
   autoFocus: boolean,
   /** Renders UI in 'disabled' state. */


Test patch:
diff --git a/src/input/__tests__/__snapshots__/base-input.test.js.snap b/src/input/__tests__/__snapshots__/base-input.test.js.snap
index fa68cc01e..4e223c75f 100644
--- a/src/input/__tests__/__snapshots__/base-input.test.js.snap
+++ b/src/input/__tests__/__snapshots__/base-input.test.js.snap
@@ -29,6 +29,7 @@ Object {
   "aria-label": null,
   "aria-labelledby": null,
   "aria-required": false,
+  "autoComplete": "on",
   "children": null,
   "disabled": false,
   "id": undefined,
diff --git a/src/input/__tests__/__snapshots__/input.test.js.snap b/src/input/__tests__/__snapshots__/input.test.js.snap
index ebb3d4a28..ebd371b20 100644
--- a/src/input/__tests__/__snapshots__/input.test.js.snap
+++ b/src/input/__tests__/__snapshots__/input.test.js.snap
@@ -7,6 +7,7 @@ Object {
   "aria-label": null,
   "aria-labelledby": null,
   "aria-required": false,
+  "autoComplete": "on",
   "children": null,
   "disabled": false,
   "id": undefined,
@@ -58,6 +59,7 @@ Object {
       aria-label={null}
       aria-labelledby={null}
       aria-required={false}
+      autoComplete="on"
       disabled={false}
       name=""
       onBlur={[Function]}
@@ -116,6 +118,7 @@ Object {
       aria-label={null}
       aria-labelledby={null}
       aria-required={false}
+      autoComplete="on"
       disabled={false}
       name=""
       onBlur={[Function]}
@@ -174,6 +177,7 @@ Object {
       aria-label={null}
       aria-labelledby={null}
       aria-required={false}
+      autoComplete="on"
       disabled={false}
       name=""
       onBlur={[Function]}
diff --git a/src/input/__tests__/__snapshots__/masked-input.test.js.snap b/src/input/__tests__/__snapshots__/masked-input.test.js.snap
index 4632b8419..519fc20f9 100644
--- a/src/input/__tests__/__snapshots__/masked-input.test.js.snap
+++ b/src/input/__tests__/__snapshots__/masked-input.test.js.snap
@@ -51,6 +51,7 @@ Object {
   "aria-label": null,
   "aria-labelledby": null,
   "aria-required": false,
+  "autoComplete": "on",
   "autoFocus": false,
   "id": undefined,
   "name": "",
diff --git a/src/input/__tests__/__snapshots__/stateful-input.test.js.snap b/src/input/__tests__/__snapshots__/stateful-input.test.js.snap
index da71e28b8..588a5e168 100644
--- a/src/input/__tests__/__snapshots__/stateful-input.test.js.snap
+++ b/src/input/__tests__/__snapshots__/stateful-input.test.js.snap
@@ -2,6 +2,7 @@
 
 exports[`basic render: renders <Input/> as a child 1`] = `
 <Input
+  autoComplete="on"
   autoFocus={false}
   disabled={false}
   endEnhancer={null}
diff --git a/src/textarea/__tests__/__snapshots__/textarea.test.js.snap b/src/textarea/__tests__/__snapshots__/textarea.test.js.snap
index a048b95f6..8a3a5773a 100644
--- a/src/textarea/__tests__/__snapshots__/textarea.test.js.snap
+++ b/src/textarea/__tests__/__snapshots__/textarea.test.js.snap
@@ -7,6 +7,7 @@ Object {
   "aria-label": null,
   "aria-labelledby": null,
   "aria-required": false,
+  "autoComplete": "on",
   "children": "textarea value",
   "disabled": false,
   "id": undefined,
@@ -31,6 +32,7 @@ Object {
   "aria-describedby": null,
   "aria-label": null,
   "aria-labelledby": null,
+  "autoComplete": "on",
   "autoFocus": false,
   "data-baseweb": "textarea",
   "disabled": false,
@@ -68,6 +70,7 @@ Object {
   "aria-describedby": null,
   "aria-label": null,
   "aria-labelledby": null,
+  "autoComplete": "on",
   "autoFocus": false,
   "data-baseweb": "textarea",
   "disabled": false,