message_edit: Make enter save when editing topics.

Fixes #1272.
This commit is contained in:
Tim Abbott 2016-10-25 16:15:23 -07:00
parent ff575aed99
commit 05a2e57b14
1 changed files with 11 additions and 9 deletions

View File

@ -117,17 +117,19 @@ function handle_edit_keydown(from_topic_edited_only, e) {
if (e.target.id === "message_edit_content" && code === 13 &&
(e.metaKey || e.ctrlKey)) {
row = $(".message_edit_content").filter(":focus").closest(".message_row");
if (message_edit.save(row, from_topic_edited_only) === true) {
message_edit.end(row);
}
} else if (e.target.id === "message_edit_topic" && code === 13) {
// Hitting enter in topic field isn't so great.
e.stopPropagation();
e.preventDefault();
row = $(e.target).closest(".message_row");
} else if (e.target.id === "inline_topic_edit" && code === 13) {
// Hitting enter in topic field isn't so great.
row = $(e.target).closest(".recipient_row");
} else {
return;
}
e.stopPropagation();
e.preventDefault();
// If no changes were made, cancel the edit (if changes were made,
// the edit window will get cleaned up by the rerendering process)
if (message_edit.save(row, from_topic_edited_only)) {
message_edit.end(row);
}
}