From 13a45c040d671c8b160835e501e2f1a4620e1447 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 19 Mar 2022 02:20:17 +0300 Subject: [PATCH 1/4] revert remove hint --- src/components/TextInput/BaseTextInput.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js index 9e2693f2d333..5e83115c9f83 100644 --- a/src/components/TextInput/BaseTextInput.js +++ b/src/components/TextInput/BaseTextInput.js @@ -11,7 +11,6 @@ import themeColors from '../../styles/themes/default'; import styles from '../../styles/styles'; import Icon from '../Icon'; import * as Expensicons from '../Icon/Expensicons'; -import InlineErrorText from '../InlineErrorText'; import Text from '../Text'; import * as styleConst from './styleConst'; import * as StyleUtils from '../../styles/StyleUtils'; @@ -188,6 +187,8 @@ class BaseTextInput extends Component { // eslint-disable-next-line react/forbid-foreign-prop-types const inputProps = _.omit(this.props, _.keys(baseTextInputPropTypes.propTypes)); const hasLabel = Boolean(this.props.label.length); + const inputHelpText = this.props.errorText || this.props.hint; + const formHelpStyles = this.props.errorText ? styles.formError : styles.formHelp; const placeholder = (this.props.prefixCharacter || this.state.isFocused || !hasLabel || (hasLabel && this.props.forceActiveLabel)) ? this.props.placeholder : null; const textInputContainerStyles = _.reduce([ styles.textInputContainer, @@ -286,9 +287,11 @@ class BaseTextInput extends Component { - - {this.props.errorText} - + {(!_.isEmpty(inputHelpText)) && ( + + {inputHelpText} + + )} {/* Text input component doesn't support auto grow by default. From 1962e12b6fe06bf3623ca25086d33b237556bb08 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 19 Mar 2022 03:29:25 +0300 Subject: [PATCH 2/4] remove extra parentheses Co-authored-by: Rajat Parashar --- src/components/TextInput/BaseTextInput.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js index 5e83115c9f83..edda63c2b6fb 100644 --- a/src/components/TextInput/BaseTextInput.js +++ b/src/components/TextInput/BaseTextInput.js @@ -287,7 +287,7 @@ class BaseTextInput extends Component { - {(!_.isEmpty(inputHelpText)) && ( + {!_.isEmpty(inputHelpText) && ( {inputHelpText} From 970e9c2e09616132c5df8982d3aabdc470154cfa Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 25 Mar 2022 17:00:46 +0300 Subject: [PATCH 3/4] add comment explaining why value is in state --- src/components/TextInput/BaseTextInput.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js index edda63c2b6fb..e83cdaac27d6 100644 --- a/src/components/TextInput/BaseTextInput.js +++ b/src/components/TextInput/BaseTextInput.js @@ -29,6 +29,8 @@ class BaseTextInput extends Component { passwordHidden: props.secureTextEntry, textInputWidth: 0, prefixWidth: 0, + + // Value should be kept in state for the autoGrow feature to work - https://github.com/Expensify/App/pull/8232#issuecomment-1077282006 value, }; From fe3775851e725dafd05ae571740d0a5fc4b6aab8 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 25 Mar 2022 17:16:00 +0300 Subject: [PATCH 4/4] cleanup - use _.isUndefined --- src/components/TextInput/BaseTextInput.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js index e83cdaac27d6..0c12fee0cfb0 100644 --- a/src/components/TextInput/BaseTextInput.js +++ b/src/components/TextInput/BaseTextInput.js @@ -64,7 +64,7 @@ class BaseTextInput extends Component { componentDidUpdate() { // Activate or deactivate the label when value is changed programmatically from outside // Only update when value prop is provided - if (this.props.value === undefined || this.state.value === this.props.value) { + if (_.isUndefined(this.props.value) || this.state.value === this.props.value) { return; }