diff --git a/src/admin-theme/wwwroot/admin.js b/src/admin-theme/wwwroot/admin.js index 1c8eb8c..d585e3f 100644 --- a/src/admin-theme/wwwroot/admin.js +++ b/src/admin-theme/wwwroot/admin.js @@ -413,6 +413,7 @@ this.Admin = { toast.setAttribute("role", "alert") toast.setAttribute("aria-live", "assertive") toast.setAttribute("aria-atomic", "true") + toast.setAttribute("data-mwl-shown", "true") toast.appendChild(toastHead) toast.appendChild(toastBody) @@ -430,15 +431,14 @@ this.Admin = { * Initialize any toasts that were pre-rendered from the server */ showPreRenderedMessages() { - [...document.querySelectorAll(".toast")].forEach(el => { - if (el.getAttribute("data-mwl-shown") !== "true") { + [...document.querySelectorAll(".toast")] + .filter(el => !el.hasAttribute("data-mwl-shown")) + .forEach(el => { const toast = new bootstrap.Toast(el, - el.getAttribute("data-bs-autohide") === "false" - ? { autohide: false } : { delay: 6000, autohide: true }) + el.getAttribute("data-bs-autohide") === "false" ? { autohide: false } : { delay: 6000, autohide: true }) toast.show() el.setAttribute("data-mwl-shown", "true") - } - }) + }) } }