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
This commit is contained in:
Riken Shah 2021-07-10 18:01:38 +00:00 committed by Tim Abbott
parent 0dbc7e0d21
commit 801ebba7c7
2 changed files with 9 additions and 8 deletions

View File

@ -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}) => {

View File

@ -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;
}