From ec717fe519cba8b726d3b2261f187c8fd67a2602 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 10 Mar 2022 16:36:06 +0530 Subject: [PATCH] Clean up and refactor --- src/components/TextInput/BaseTextInput.js | 12 ++---------- src/components/TextInput/baseTextInputPropTypes.js | 1 - src/stories/Composer.stories.js | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js index 9e9a6622357b..a8be3ecec95d 100644 --- a/src/components/TextInput/BaseTextInput.js +++ b/src/components/TextInput/BaseTextInput.js @@ -190,6 +190,7 @@ class BaseTextInput extends Component { 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, ...this.props.textInputContainerStyles, @@ -251,16 +252,7 @@ class BaseTextInput extends Component { // eslint-disable-next-line {...inputProps} defaultValue={this.state.value} - placeholder={ - ( - this.props.prefixCharacter - || this.state.isFocused - || !hasLabel - || (hasLabel && this.props.forceActiveLabel) - ) - ? this.props.placeholder - : null - } + placeholder={placeholder} placeholderTextColor={themeColors.placeholderText} underlineColorAndroid="transparent" style={[ diff --git a/src/components/TextInput/baseTextInputPropTypes.js b/src/components/TextInput/baseTextInputPropTypes.js index e6a612d73205..89ea048cd35d 100644 --- a/src/components/TextInput/baseTextInputPropTypes.js +++ b/src/components/TextInput/baseTextInputPropTypes.js @@ -57,7 +57,6 @@ const propTypes = { prefixCharacter: PropTypes.string, /** Form props */ - /** Indicates that the input is being used with the Form component */ isFormInput: PropTypes.bool, diff --git a/src/stories/Composer.stories.js b/src/stories/Composer.stories.js index 486b2afa61e9..6e3be856668c 100644 --- a/src/stories/Composer.stories.js +++ b/src/stories/Composer.stories.js @@ -25,9 +25,9 @@ const parser = new ExpensiMark(); const Default = (args) => { const [pastedFile, setPastedFile] = useState(null); const [comment, setComment] = useState(args.defaultValue); - const renderedHTML = parser.replace(comment); const [droppingFile, setDroppingFile] = useState(false); const [isComposerDroppingTarget, setIsComposerDroppingTarget] = useState(false); + const renderedHTML = parser.replace(comment); return (