From 44e60d12e30f2c85622e0bd892e27ec47a2dcee2 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Fri, 28 Oct 2016 10:51:05 -0700 Subject: [PATCH] [change] TextInput support for autoCorrect and autoComplete --- docs/components/TextInput.md | 11 ++++++++--- src/components/TextInput/index.js | 9 +++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/components/TextInput.md b/docs/components/TextInput.md index a4ff31ac..dc983360 100644 --- a/docs/components/TextInput.md +++ b/docs/components/TextInput.md @@ -29,13 +29,18 @@ Automatically capitalize certain characters (only available in Chrome and iOS Sa * `sentences`: Automatically capitalize the first letter of sentences. * `words`: Automatically capitalize the first letter of words. -(web) **autoComplete**: bool = false +(web) **autoComplete**: string -Indicates whether the value of the control can be automatically completed by the browser. +Indicates whether the value of the control can be automatically completed by +the browser. [Accepted values](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). + +**autoCorrect**: bool = true + +Automatically correct spelling mistakes (only available in iOS Safari). **autoFocus**: bool = false -If true, focuses the input on `componentDidMount`. Only the first form element +If `true`, focuses the input on `componentDidMount`. Only the first form element in a document with `autofocus` is focused. **clearTextOnFocus**: bool = false diff --git a/src/components/TextInput/index.js b/src/components/TextInput/index.js index fa088a5a..28b36ea4 100644 --- a/src/components/TextInput/index.js +++ b/src/components/TextInput/index.js @@ -20,7 +20,8 @@ class TextInput extends Component { static propTypes = { ...View.propTypes, autoCapitalize: PropTypes.oneOf([ 'characters', 'none', 'sentences', 'words' ]), - autoComplete: PropTypes.bool, + autoComplete: PropTypes.string, + autoCorrect: PropTypes.bool, autoFocus: PropTypes.bool, clearTextOnFocus: PropTypes.bool, defaultValue: PropTypes.string, @@ -49,6 +50,8 @@ class TextInput extends Component { static defaultProps = { autoCapitalize: 'sentences', + autoComplete: 'on', + autoCorrect: true, editable: true, keyboardType: 'default', multiline: false, @@ -87,6 +90,7 @@ class TextInput extends Component { accessibilityLabel, // eslint-disable-line autoCapitalize, autoComplete, + autoCorrect, autoFocus, defaultValue, editable, @@ -142,7 +146,8 @@ class TextInput extends Component { const propsCommon = { autoCapitalize, - autoComplete: autoComplete && 'on', + autoComplete, + autoCorrect: autoCorrect ? 'on' : 'off', autoFocus, defaultValue, maxLength,