From e00a80d32b44129e1c561202d69f683746b3fb36 Mon Sep 17 00:00:00 2001 From: wpalani Date: Tue, 8 Oct 2024 17:45:30 -0700 Subject: [PATCH] Listen to all dismiss actions in a message This should address a bug https://jira.newfold.com/browse/PRESS0-2274 when a user clicks "No Thanks" the modal closes but the messages is not dismissed. --- assets/js/dismiss-notices.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/js/dismiss-notices.js b/assets/js/dismiss-notices.js index ca3de72..a5b0ca7 100644 --- a/assets/js/dismiss-notices.js +++ b/assets/js/dismiss-notices.js @@ -61,9 +61,13 @@ const addEventListeners = (el) => { // Handle notification close/dismiss events - const closeButton = el.querySelector('[data-action="close"]'); - if (closeButton) { - closeButton.addEventListener('click', dismissNotice); + const closeButtons = Array.from(el.querySelectorAll('[data-action="close"]')); + if (closeButtons.length) { + closeButtons.forEach( + closeButton => { + closeButton.addEventListener('click', dismissNotice); + } + ) } // Handle notification button click event tracking