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.

drafts: Fix hook for saving drafts.

Tim Abbottb67b9912c4b1
diff --git a/frontend_tests/node_tests/drafts.js b/frontend_tests/node_tests/drafts.js
index d93d15b1560..030d83ad702 100644
--- a/frontend_tests/node_tests/drafts.js
+++ b/frontend_tests/node_tests/drafts.js
@@ -174,10 +174,6 @@ test("initialize", (override) => {
};
drafts.initialize();
-
- const message_content = $("#compose-textarea");
- assert.equal(message_content.get_on_handler("focusout"), drafts.update_draft);
- message_content.trigger("focusout");
});
test("remove_old_drafts", () => {
diff --git a/static/js/compose_actions.js b/static/js/compose_actions.js
index ed45279fbf3..2aa6418d146 100644
--- a/static/js/compose_actions.js
+++ b/static/js/compose_actions.js
@@ -31,6 +31,8 @@ export function blur_compose_inputs() {
}
function hide_box() {
+ // This is the main hook for saving drafts when closing the compose box.
+ drafts.update_draft();
blur_compose_inputs();
$("#stream-message").hide();
$("#private-message").hide();
diff --git a/static/js/drafts.js b/static/js/drafts.js
index 7c0944888c9..9276f6e08f6 100644
--- a/static/js/drafts.js
+++ b/static/js/drafts.js
@@ -557,8 +557,6 @@ export function initialize() {
set_count(Object.keys(draft_model.get()).length);
- $("#compose-textarea").on("focusout", update_draft);
-
$("body").on("focus", ".draft-info-box", (e) => {
activate_element(e.target);
});