From 9459fa9a0c02ba6e43be73ef64d5b30c30b34279 Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Tue, 29 Oct 2024 12:34:50 -0700 Subject: [PATCH] Fix stacked alerts --- src/registrar/assets/js/get-gov.js | 8 ++++++-- src/registrar/templates/portfolio_members.html | 3 --- src/registrar/views/portfolios.py | 10 ++++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 01a1b8d34..61daeaa5c 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -279,7 +279,7 @@ function deleteMember(member_delete_url, pageToDisplay) { */ function addAlert(alertClass, alertMessage) { let toggleableAlertDiv = document.getElementById("toggleable-alert"); - this.resetAlert(); + this.resetAlerts(); toggleableAlertDiv.classList.add(`usa-alert--${alertClass}`); let alertParagraph = toggleableAlertDiv.querySelector(".usa-alert__text"); alertParagraph.innerHTML = alertMessage @@ -290,7 +290,11 @@ function addAlert(alertClass, alertMessage) { * Resets the reusable alert message * */ -function resetAlert() { +function resetAlerts() { + // Create a list of any alert that's leftover and remove + document.querySelectorAll(".usa-alert:not(#toggleable-alert)").forEach(alert => { + alert.remove(); + }); let toggleableAlertDiv = document.getElementById("toggleable-alert"); toggleableAlertDiv.classList.remove('usa-alert--error'); toggleableAlertDiv.classList.remove('usa-alert--success'); diff --git a/src/registrar/templates/portfolio_members.html b/src/registrar/templates/portfolio_members.html index ed7139e8b..ed2f3f09b 100644 --- a/src/registrar/templates/portfolio_members.html +++ b/src/registrar/templates/portfolio_members.html @@ -9,9 +9,6 @@ {% endblock %} {% block portfolio_content %} -{% block messages %} - {% include "includes/form_messages.html" %} -{% endblock %}