From 9ef3a194511513d8d38cc2ce87c48feb3b79804e Mon Sep 17 00:00:00 2001 From: whilstsomebody Date: Sat, 26 Apr 2025 10:42:39 +0530 Subject: [PATCH] compose: Prevent displaying banner when channel picker is opened. Prevent displaying the topic resolved banner when the channel picker (compose_select_recipient_dropdown_widget) is opened in the case of forwarding messages. This is done to prevent the overlap of the channel picker and the banner, as it hides some part of the banner text. Fixes: #33449 --- web/src/compose_recipient.ts | 2 ++ web/src/compose_reply.ts | 2 +- web/src/compose_setup.js | 6 +++++- web/src/compose_state.ts | 9 +++++++++ web/src/compose_validate.ts | 11 +++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/web/src/compose_recipient.ts b/web/src/compose_recipient.ts index 4a6f309906..a90ab8990b 100644 --- a/web/src/compose_recipient.ts +++ b/web/src/compose_recipient.ts @@ -312,6 +312,8 @@ function on_show_callback(): void { // NOTE: Since tippy triggers this on `mousedown` it is always triggered before say a `click` on `textarea`. function on_hidden_callback(): void { $("#compose_select_recipient_widget").removeClass("widget-open"); + compose_state.set_is_processing_forward_message(false); + compose_validate.warn_if_topic_resolved(false); if (!compose_select_recipient_dropdown_widget.item_clicked) { // If the dropdown was NOT closed due to selecting an item, // don't do anything. diff --git a/web/src/compose_reply.ts b/web/src/compose_reply.ts index e76621c3ca..81d81bed98 100644 --- a/web/src/compose_reply.ts +++ b/web/src/compose_reply.ts @@ -256,7 +256,7 @@ export function quote_message(opts: { topic = message.topic; stream_id = message.stream_id; } - + compose_state.set_is_processing_forward_message(true); compose_actions.start({ message_type: message.type, topic, diff --git a/web/src/compose_setup.js b/web/src/compose_setup.js index ee5ae06bd1..99ffab0766 100644 --- a/web/src/compose_setup.js +++ b/web/src/compose_setup.js @@ -74,7 +74,11 @@ export function initialize() { if ($("#compose").hasClass("preview_mode")) { compose.render_preview_area(); } - compose_validate.warn_if_topic_resolved(false); + const recipient_widget_hidden = + $(".compose_select_recipient-dropdown-list-container").length === 0; + if (recipient_widget_hidden) { + compose_validate.warn_if_topic_resolved(false); + } const compose_text_length = compose_validate.check_overflow_text($("#send_message_form")); // Change compose close button tooltip as per condition. diff --git a/web/src/compose_state.ts b/web/src/compose_state.ts index 1a058ce3d8..55af191c61 100644 --- a/web/src/compose_state.ts +++ b/web/src/compose_state.ts @@ -10,6 +10,7 @@ let recipient_edited_manually = false; let is_content_unedited_restored_draft = false; let last_focused_compose_type_input: HTMLTextAreaElement | undefined; let preview_render_count = 0; +let is_processing_forward_message = false; // We use this variable to keep track of whether user has viewed the topic resolved // banner for the current compose session, for a narrow. This prevents the banner @@ -85,6 +86,14 @@ export function set_preview_render_count(count: number): void { preview_render_count = count; } +export function set_is_processing_forward_message(val: boolean): void { + is_processing_forward_message = val; +} + +export function get_is_processing_forward_message(): boolean { + return is_processing_forward_message; +} + export function composing(): boolean { // This is very similar to get_message_type(), but it returns // a boolean. diff --git a/web/src/compose_validate.ts b/web/src/compose_validate.ts index 912f8610b3..81cbf60d89 100644 --- a/web/src/compose_validate.ts +++ b/web/src/compose_validate.ts @@ -439,6 +439,17 @@ export function warn_if_topic_resolved(topic_changed: boolean): void { // // Pass topic_changed=true if this function was called in response // to a topic being edited. + const recipient_widget_hidden = + $(".compose_select_recipient-dropdown-list-container").length === 0; + if (compose_state.get_is_processing_forward_message() && recipient_widget_hidden) { + // This is for the case of forwarding a message when the + // channel picker is opened. There is a possibility that + // this banner might be displayed at the same time the + // channel picker is opened. We don't want that situation. + // Therefore, we are preventing the display of this + // banner when the channel picker is opened. + return; + } const stream_id = compose_state.stream_id(); if (stream_id === undefined) {