mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 01:18:34 +00:00
disable empty string submissions
This commit is contained in:
1 parent
b87191a158
commit
8dbc58ffa1
1 file changed
+14
-1
@@ -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";
|
||||
|
||||
Reference in new issue
Block a user