]> cat aescling's git repositories - mastodon.git/commitdiff
Fix: Prevent submission using same logic as submit button disabling. (#6993)
authorEmelia Smith <ThisIsMissEm@users.noreply.github.com>
Sun, 1 Apr 2018 20:19:43 +0000 (22:19 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 1 Apr 2018 20:19:43 +0000 (22:19 +0200)
This prevents submission through ctrl/cmd+enter when the submit button is disabled.

app/javascript/mastodon/features/compose/components/compose_form.js

index 663ccfb8eac26dc78287bb4b1c783fa933e304be..fe7bb1cb38edb115c1a00564082bbcdc31b89cf9 100644 (file)
@@ -74,6 +74,14 @@ export default class ComposeForm extends ImmutablePureComponent {
       this.props.onChange(this.autosuggestTextarea.textarea.value);
     }
 
+    // Submit disabled:
+    const { is_submitting, is_uploading, anyMedia } = this.props;
+    const fulltext = [this.props.spoiler_text, countableText(this.props.text)].join('');
+
+    if (is_submitting || is_uploading || length(fulltext) > 500 || (fulltext.length !== 0 && fulltext.trim().length === 0 && !anyMedia)) {
+      return;
+    }
+
     this.props.onSubmit();
   }