From 54ad2f5266acab7f8c8a1431880ecb594dd72e73 Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Fri, 4 Nov 2022 18:58:39 +0100 Subject: [PATCH] compose-actions: Stop compose box load for invalid users with any trigger. A user could trigger a "pm-with" narrow with an invalid user by moving back/forward in the session, which would trigger the compose box to open via a hash change. Updates the check to pass in any "pm-with" narrow with an invalid user. Also, if the compose box was active/started in the previous view, but without any content, then we want to actively cancel/close it in the invalid user "pm-with" narrow. --- static/js/compose_actions.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/static/js/compose_actions.js b/static/js/compose_actions.js index a0d0a9c7f6..9874266a2a 100644 --- a/static/js/compose_actions.js +++ b/static/js/compose_actions.js @@ -632,9 +632,11 @@ export function on_narrow(opts) { if (narrow_state.narrowed_by_pm_reply()) { opts = fill_in_opts_from_current_narrowed_view("private", opts); - // Do not open compose box if triggered by search and invalid recipient - // is present. - if (opts.trigger === "search" && !opts.private_message_recipient) { + // Do not open compose box if an invalid recipient is present. + if (!opts.private_message_recipient) { + if (compose_state.composing()) { + cancel(); + } return; } // Do not open compose box if organization has disabled sending