disable empty string submissions

This commit is contained in:
Brandon Thomas committed 2020-10-10 00:21:20 -04:00
1 parent b87191a158
commit 8dbc58ffa1
1 file changed
+14 -1
+14 -1
View File
@@ -222,12 +222,25 @@ class Form extends React.Component<Props, State> {
this.textarea?.focus();
}
nonSpaceCharacterCount() : number {
return this.props.currentText.trim().length;
}
remainingCharacterCount() : number {
return this.props.textCharacterLimit - this.props.currentText.length;
}
public render() {
let remainingCharacters = this.props.textCharacterLimit - this.props.currentText.length;
const nonWhitespaceCharacters = this.nonSpaceCharacterCount();
const remainingCharacters = this.remainingCharacterCount();
let remainingCharactersButtonDisabled = false;
let remainingCharactersClassName = "";
if (nonWhitespaceCharacters === 0) {
remainingCharactersButtonDisabled= true;
}
if (remainingCharacters < 0) {
remainingCharactersButtonDisabled= true;
remainingCharactersClassName = "has-text-danger";