From 801ebba7c7f8a83560b7745e6b1fbbac1116f08a Mon Sep 17 00:00:00 2001 From: Riken Shah Date: Sat, 10 Jul 2021 18:01:38 +0000 Subject: [PATCH] compose: Avoid showing empty msg error when send by enter is enabled. We are doing this to avoid annoying behavior, when "enter sends" is enabled, and the user accidentally hits "Enter" and has to deal with the error message. Fixes #19182 --- frontend_tests/node_tests/compose.js | 5 +---- static/js/compose_validate.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js index 4c87483221..5045d060c0 100644 --- a/frontend_tests/node_tests/compose.js +++ b/frontend_tests/node_tests/compose.js @@ -518,10 +518,7 @@ test_ui("enter_with_preview_open", ({override}) => { compose.enter_with_preview_open(); assert.ok($("#enter_sends").prop("checked")); - assert.equal( - $("#compose-error-msg").html(), - $t_html({defaultMessage: "You have nothing to send!"}), - ); + assert.equal($("#compose-error-msg").html(), "never-been-set"); }); test_ui("finish", ({override}) => { diff --git a/static/js/compose_validate.js b/static/js/compose_validate.js index 948b8f3eae..cc612a3d62 100644 --- a/static/js/compose_validate.js +++ b/static/js/compose_validate.js @@ -522,10 +522,14 @@ export function validate() { } if (/^\s*$/.test(message_content)) { - compose_error.show( - $t_html({defaultMessage: "You have nothing to send!"}), - $("#compose-textarea"), - ); + // Avoid showing an error message when "enter sends" is enabled, + // as it is more likely that the user has hit "Enter" accidentally. + if (!page_params.enter_sends) { + compose_error.show( + $t_html({defaultMessage: "You have nothing to send!"}), + $("#compose-textarea"), + ); + } return false; }