Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_edit: Attach keydown to $form instead of textarea.

Aman Agrawala35c8a08de21
diff --git a/web/src/composebox_typeahead.ts b/web/src/composebox_typeahead.ts
index 1f790f580e1..426c1e53aaf 100644
--- a/web/src/composebox_typeahead.ts
+++ b/web/src/composebox_typeahead.ts
@@ -1305,7 +1305,9 @@ export function initialize({
}: {
on_enter_send: (scheduling_message?: boolean) => boolean | undefined;
}): void {
- // These handlers are at the "form" level so that they are called after typeahead
+ // Attach event handlers to `form` instead of `textarea` to allow
+ // typeahead to call stopPropagation if it can handle the event
+ // and prevent the form from submitting.
$("form#send_message_form").on("keydown", (e) => {
handle_keydown(e, on_enter_send);
});
diff --git a/web/src/message_edit.ts b/web/src/message_edit.ts
index 50a9f21fa3f..104d70c9c16 100644
--- a/web/src/message_edit.ts
+++ b/web/src/message_edit.ts
@@ -508,7 +508,10 @@ function edit_message($row: JQuery, raw_content: string): void {
currently_editing_messages.set(message.id, $message_edit_content);
message_lists.current.show_edit_message($row, $form);
- $message_edit_content.on("keydown", (e) => {
+ // Attach event handlers to `form` instead of `textarea` to allow
+ // typeahead to call stopPropagation if it can handle the event
+ // and prevent the form from submitting.
+ $form.on("keydown", (e) => {
if (keydown_util.is_enter_event(e)) {
handle_message_edit_enter(e, $message_edit_content);
}