mirror of
https://github.com/zulip/zulip.git
synced 2025-11-21 15:09:34 +00:00
message_edit: Refactor message edit keydown handler.
This commit modifies handle_message_row_edit_keydown to use keydown_util.is_enter_event(). This is a precursor to fixing #22062.
This commit is contained in:
committed by
Tim Abbott
parent
836f0fed10
commit
56970ee117
@@ -317,8 +317,7 @@ export function end_if_focused_on_message_row_edit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handle_message_row_edit_keydown(e) {
|
function handle_message_row_edit_keydown(e) {
|
||||||
switch (e.key) {
|
if (keydown_util.is_enter_event(e)) {
|
||||||
case "Enter":
|
|
||||||
if ($(e.target).hasClass("message_edit_content")) {
|
if ($(e.target).hasClass("message_edit_content")) {
|
||||||
// Pressing Enter to save edits is coupled with Enter to send
|
// Pressing Enter to save edits is coupled with Enter to send
|
||||||
if (composebox_typeahead.should_enter_send(e)) {
|
if (composebox_typeahead.should_enter_send(e)) {
|
||||||
@@ -352,14 +351,10 @@ function handle_message_row_edit_keydown(e) {
|
|||||||
save_message_row_edit($row);
|
save_message_row_edit($row);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
return;
|
} else if (e.key === "Escape") {
|
||||||
case "Escape": // Handle escape keys in the message_edit form.
|
|
||||||
end_if_focused_on_message_row_edit();
|
end_if_focused_on_message_row_edit();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user