compose: Clear preview UI when recipient change clears compose box.

Previously, we cleared the preview element only when cancelling
compose, which meant the compose box would be left in an invalid
state, showing a preview from a no longer active draft, if switching
recipients with it open.

Fix this by moving the call to clear the preview state to clear_box,
which is called in both the hide_box (close compose) and change
recipient code paths for clearing compose after not having sent a
message.

Fixes #22703.
This commit is contained in:
Sean Heckathorne
2022-08-23 04:41:09 -05:00
committed by Tim Abbott
parent 011233d016
commit 6728ee1f0e

View File

@@ -44,7 +44,6 @@ function hide_box() {
compose_fade.clear_compose();
$(".message_comp").hide();
$("#compose_controls").show();
compose.clear_preview_area();
}
function get_focus_area(msg_type, opts) {
@@ -111,6 +110,7 @@ function clear_box() {
compose.clear_private_stream_alert();
compose_validate.set_user_acknowledged_all_everyone_flag(undefined);
compose.clear_preview_area();
clear_textarea();
compose_validate.check_overflow_text();
$("#compose-textarea").removeData("draft-id");