mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +00:00
compose: Save messages as drafts when window loses focus.
Add a check for window blur and save any in-progress messages as drafts. This will help prevent unnecessary message loss for the user by creating drafts for them more whenever they switch away from their Zulip tab. Tested on my local Ubuntu development with a demo organization and some of the premade profiles. Fixes #35262.
This commit is contained in:
@@ -18,6 +18,7 @@ import * as compose_state from "./compose_state.ts";
|
||||
import * as compose_ui from "./compose_ui.ts";
|
||||
import * as compose_validate from "./compose_validate.ts";
|
||||
import * as dialog_widget from "./dialog_widget.ts";
|
||||
import * as drafts from "./drafts.ts";
|
||||
import * as flatpickr from "./flatpickr.ts";
|
||||
import {$t_html} from "./i18n.ts";
|
||||
import * as message_edit from "./message_edit.ts";
|
||||
@@ -626,6 +627,12 @@ export function initialize() {
|
||||
compose_recipient.set_high_attention_recipient_row();
|
||||
});
|
||||
|
||||
$(window).on("blur", () => {
|
||||
// Save drafts when the window loses focus to help
|
||||
// ensure no work is lost
|
||||
drafts.update_draft();
|
||||
});
|
||||
|
||||
$("body").on("click", ".formatting_button", function (e) {
|
||||
const $compose_click_target = $(this);
|
||||
const $textarea = $compose_click_target.closest("form").find("textarea");
|
||||
|
||||
Reference in New Issue
Block a user