compose_actions: Hide compose box when navigating to inbox/recent view.

Currently, given that the compose box is already open, it stays open
when the user navigates to the inbox/recent view, even when there is
no modifications to the message or recipients.

This commit adds conditions to close the compose box when navigating
to the inbox/recent view, except when we can reasonably infer that it
was the intended action.
This commit is contained in:
Sayam Samal 2023-12-13 09:15:44 +05:30 committed by Tim Abbott
parent f281199d2f
commit 7f26905fe0
2 changed files with 20 additions and 0 deletions

View File

@ -336,6 +336,24 @@ export function cancel() {
$(document).trigger("compose_canceled.zulip");
}
export function on_show_navigation_view() {
/* This function dictates the behavior of the compose box
* when navigating to a view, as opposed to a narrow. */
// Leave the compose box closed if it was already closed.
if (!compose_state.composing()) {
return;
}
// Leave the compose box open if there is content or if the recipient was edited.
if (compose_state.has_message_content() || compose_state.is_recipient_edited_manually()) {
return;
}
// Otherwise, close the compose box.
cancel();
}
export function on_topic_narrow() {
if (!compose_state.composing()) {
// If our compose box is closed, then just

View File

@ -1,5 +1,6 @@
import $ from "jquery";
import * as compose_actions from "./compose_actions";
import * as compose_recipient from "./compose_recipient";
import * as dropdown_widget from "./dropdown_widget";
import {$t} from "./i18n";
@ -87,6 +88,7 @@ export function show(opts) {
compose_recipient.handle_middle_pane_transition();
search.clear_search_form();
opts.complete_rerender();
compose_actions.on_show_navigation_view();
// Misc.
if (opts.is_recent_view) {