compose: Fix behavior hitting enter with the preview area open.

The new behavior is:
(1) If enter-sends is enabled, just send the messsage.
(2) If enter-sends is not enabled, return focus to the compose area.

Based on great work by khantaalaman in #3673.

Fixes #3489.
This commit is contained in:
Tim Abbott
2017-02-18 22:43:02 -08:00
parent 08a7e0db44
commit e29663a2b3
2 changed files with 17 additions and 0 deletions

View File

@@ -607,6 +607,17 @@ function send_message(request) {
}
}
exports.enter_with_preview_open = function () {
clear_preview_area();
if (page_params.enter_sends) {
// If enter_sends is enabled, we just send the message
send_message();
} else {
// Otherwise, we return to the compose box and focus it
$("#new_message_content").focus();
}
};
exports.respond_to_message = function (opts) {
var message;
var msg_type;