about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmelia Smith <ThisIsMissEm@users.noreply.github.com>2018-04-01 22:19:43 +0200
committerEugen Rochko <eugen@zeonfederated.com>2018-04-01 22:19:43 +0200
commit6a895e1ab3d69cd018423460518a1e16307999ad (patch)
tree7ac966e3fac03474530f7fb791ccde2ce4256bd8
parent993ce0e5a7d86330d1ac7a9123735d8a218652b3 (diff)
Fix: Prevent submission using same logic as submit button disabling. (#6993)
This prevents submission through ctrl/cmd+enter when the submit button is disabled.
-rw-r--r--app/javascript/mastodon/features/compose/components/compose_form.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js
index 663ccfb8e..fe7bb1cb3 100644
--- a/app/javascript/mastodon/features/compose/components/compose_form.js
+++ b/app/javascript/mastodon/features/compose/components/compose_form.js
@@ -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();
   }