From d96fac2b591cfbcd0992ad82d381187e43e9fef0 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 2 May 2023 13:02:56 -0700 Subject: [PATCH] compose: Fix compose banner click handlers when editing messages. The click handlers for compose banners, many of which can appear both in the message editing code path and above the compose box, were incorrectly scoped to only the #compose_banners container. These click handlers were all overly specific; they already have a very unique selector in the form of things like .compose_banner_close_button, and more shouldn't be necessary. --- web/src/compose.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/web/src/compose.js b/web/src/compose.js index 434cb470df..139e9ccb03 100644 --- a/web/src/compose.js +++ b/web/src/compose.js @@ -465,7 +465,7 @@ export function initialize() { upload.feature_check($("#compose .compose_upload_file")); - $("#compose_banners").on( + $("body").on( "click", `.${CSS.escape(compose_banner.CLASSNAMES.wildcard_warning)} .compose_banner_action_button`, (event) => { @@ -479,7 +479,7 @@ export function initialize() { const user_not_subscribed_selector = `.${CSS.escape( compose_banner.CLASSNAMES.user_not_subscribed, )}`; - $("#compose_banners").on( + $("body").on( "click", `${user_not_subscribed_selector} .compose_banner_action_button`, (event) => { @@ -495,7 +495,7 @@ export function initialize() { }, ); - $("#compose_banners").on( + $("body").on( "click", `.${CSS.escape(compose_banner.CLASSNAMES.topic_resolved)} .compose_banner_action_button`, (event) => { @@ -512,7 +512,7 @@ export function initialize() { }, ); - $("#compose_banners").on( + $("body").on( "click", `.${CSS.escape( compose_banner.CLASSNAMES.unmute_topic_notification, @@ -534,7 +534,7 @@ export function initialize() { }, ); - $("#compose_banners").on( + $("body").on( "click", `.${CSS.escape( compose_banner.CLASSNAMES.recipient_not_subscribed, @@ -574,14 +574,10 @@ export function initialize() { for (const classname of Object.values(compose_banner.CLASSNAMES)) { const classname_selector = `.${CSS.escape(classname)}`; - $("#compose_banners").on( - "click", - `${classname_selector} .compose_banner_close_button`, - (event) => { - event.preventDefault(); - $(event.target).parents(classname_selector).remove(); - }, - ); + $("body").on("click", `${classname_selector} .compose_banner_close_button`, (event) => { + event.preventDefault(); + $(event.target).parents(classname_selector).remove(); + }); } // Click event binding for "Attach files" button