mirror of
https://github.com/wassname/talk.git
synced 2026-08-05 13:30:26 +08:00
remove removeNewLine and add .trim to length variable
This commit is contained in:
@@ -82,15 +82,10 @@ export class CommentForm extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
removeNewLine = (string) => {
|
||||
return string.replace(/\n/g, '');
|
||||
}
|
||||
|
||||
render() {
|
||||
const {maxCharCount, submitEnabled, cancelButtonClassName, submitButtonClassName, charCountEnable, body, loadingState} = this.props;
|
||||
|
||||
const cleanedBody = this.removeNewLine(body);
|
||||
const length = cleanedBody.trim().length;
|
||||
const length = body.trim().length;
|
||||
const isRespectingMaxCount = (length) => charCountEnable && maxCharCount && length > maxCharCount;
|
||||
const disableSubmitButton = !length || isRespectingMaxCount(length) || !submitEnabled({body}) || loadingState === 'loading';
|
||||
const disableCancelButton = loadingState === 'loading';
|
||||
|
||||
Reference in New Issue
Block a user