From 0fbdb90554062f1d306385759757110e6e81070d Mon Sep 17 00:00:00 2001 From: Filip Messa Date: Thu, 21 Feb 2019 16:53:38 +0100 Subject: [PATCH] Refactor: unify autoFocus prop and add autoCorrect prop into the TagsInput --- src/TagsInput/TagsInput.js | 14 +++++++++----- src/TagsInput/TagsInput.stories.js | 16 ++++++++++++---- src/TagsInput/components/InputField.js | 9 ++++++--- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/TagsInput/TagsInput.js b/src/TagsInput/TagsInput.js index dc1be75..fcc3219 100644 --- a/src/TagsInput/TagsInput.js +++ b/src/TagsInput/TagsInput.js @@ -25,7 +25,8 @@ type Props = {| +onKeyPress?: (e: Event) => void, +placeholder?: string, +value?: string, - +autofocus: boolean, + +autoFocus: boolean, + +autoCorrect: boolean, |}; type State = { @@ -50,7 +51,8 @@ export default class TagsInput extends React.Component { static defaultProps = { fontSize: parseFloat(defaultTokens.fontSizeButtonLarge), tags: [], - autofocus: false, + autoFocus: false, + autoCorrect: false, }; constructor(props: Props) { @@ -60,7 +62,7 @@ export default class TagsInput extends React.Component { this.state = { value: props.value || '', - isFocus: props.autofocus, + isFocus: props.autoFocus, }; } @@ -119,7 +121,8 @@ export default class TagsInput extends React.Component { label, onKeyPress, tags, - autofocus, + autoFocus, + autoCorrect, } = this.props; const { isFocus, value } = this.state; @@ -156,7 +159,8 @@ export default class TagsInput extends React.Component { > )) @@ -29,7 +35,7 @@ storiesOf('TagsInput', module) onChangeText={action('onChangeText')} label="From:" placeholder="Departure point" - autofocus + autoFocus /> )) @@ -42,12 +48,14 @@ storiesOf('TagsInput', module) step: 1, }); const label = text('Label', 'From:'); + const autoCorrect = boolean('Auto correct', false); const placeholder = text('Placeholder', 'Departure point'); return ( void, - +autofocus?: boolean, + +autoFocus?: boolean, + +autoCorrect?: boolean, |}; type State = {| @@ -100,7 +101,8 @@ class InputField extends React.Component { onFocus, onBlur, onKeyPress, - autofocus, + autoFocus, + autoCorrect, } = this.props; const { componentWidth } = this.state; @@ -116,7 +118,8 @@ class InputField extends React.Component { return (