1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

fix: prevent sending posts when no text was entered, and no other media is attached

fixes #30512
This commit is contained in:
Maximilian Ertl 2024-05-31 21:00:47 +02:00 committed by GitHub
parent d326ad0ed9
commit 70a1f3701a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -104,9 +104,9 @@ class ComposeForm extends ImmutablePureComponent {
canSubmit = () => {
const { isSubmitting, isChangingUpload, isUploading, anyMedia, maxChars } = this.props;
const fulltext = this.getFulltextForCharacterCounting();
const isOnlyWhitespace = fulltext.length !== 0 && fulltext.trim().length === 0;
const hasNoTextContent = fulltext.trim().length === 0;
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > maxChars || (isOnlyWhitespace && !anyMedia));
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > maxChars || (hasNoTextContent && !anyMedia));
};
handleSubmit = (e) => {