add trim to prevent empty spaces, tabs and other whitespace characters

This commit is contained in:
kamos1
2017-10-06 13:19:37 -06:00
parent 57f8a64cf4
commit 8ab31d7009
+1 -1
View File
@@ -90,7 +90,7 @@ export class CommentForm extends React.Component {
const {maxCharCount, submitEnabled, cancelButtonClassName, submitButtonClassName, charCountEnable, body, loadingState} = this.props;
const cleanedBody = this.removeNewLine(body);
const length = cleanedBody.length;
const length = cleanedBody.trim().length;
const isRespectingMaxCount = (length) => charCountEnable && maxCharCount && length > maxCharCount;
const disableSubmitButton = !length || isRespectingMaxCount(length) || !submitEnabled({body}) || loadingState === 'loading';
const disableCancelButton = loadingState === 'loading';