mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
message_edit: Use e.key instead of deprecated e.keyCode.
Tested by making sure Enter and Escape works as expected for editing topics and messages.
This commit is contained in:
committed by
Tim Abbott
parent
2cb71ccc7b
commit
c292ade96a
@@ -236,9 +236,8 @@ export function end_if_focused_on_message_row_edit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handle_message_row_edit_keydown(e) {
|
function handle_message_row_edit_keydown(e) {
|
||||||
const code = e.keyCode || e.which;
|
switch (e.key) {
|
||||||
switch (code) {
|
case "Enter":
|
||||||
case 13:
|
|
||||||
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)) {
|
||||||
@@ -269,7 +268,7 @@ function handle_message_row_edit_keydown(e) {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case 27: // Handle escape keys in the message_edit form.
|
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();
|
||||||
@@ -281,15 +280,14 @@ function handle_message_row_edit_keydown(e) {
|
|||||||
|
|
||||||
function handle_inline_topic_edit_keydown(e) {
|
function handle_inline_topic_edit_keydown(e) {
|
||||||
let row;
|
let row;
|
||||||
const code = e.keyCode || e.which;
|
switch (e.key) {
|
||||||
switch (code) {
|
case "Enter": // Handle Enter key in the recipient bar/inline topic edit form
|
||||||
case 13: // Handle Enter key in the recipient bar/inline topic edit form
|
|
||||||
row = $(e.target).closest(".recipient_row");
|
row = $(e.target).closest(".recipient_row");
|
||||||
save_inline_topic_edit(row);
|
save_inline_topic_edit(row);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
case 27: // handle Esc
|
case "Escape": // handle Esc
|
||||||
end_if_focused_on_inline_topic_edit();
|
end_if_focused_on_inline_topic_edit();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user