فهرست منبع

Fixes #23746: Keep closed toast messages from reappearing (#23775)

* Fixes #23746: Keep closed toast messages from reappearing

initMessages() runs after every htmx swap and reopened any toast that
was not currently shown, so a closed toast came back on each table page
change. Mark each toast once it has been shown and skip it afterwards.

* review fixes
Arthur Hanson 10 ساعت پیش
والد
کامیت
6997809981
3فایلهای تغییر یافته به همراه7 افزوده شده و 6 حذف شده
  1. 0 0
      netbox/project-static/dist/netbox.js
  2. 0 0
      netbox/project-static/dist/netbox.js.map
  3. 7 6
      netbox/project-static/src/messages.ts

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
netbox/project-static/dist/netbox.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
netbox/project-static/dist/netbox.js.map


+ 7 - 6
netbox/project-static/src/messages.ts

@@ -8,11 +8,12 @@ export function initMessages(): void {
     'body > div#django-messages > div.toast',
   );
   for (const element of elements) {
-    if (element !== null) {
-      const toast = new Toast(element);
-      if (!toast.isShown()) {
-        toast.show();
-      }
-    }
+    // Skip toasts already showing, and closed toasts restored from an htmx history snapshot
+    const closed = element.classList.contains('fade') && !element.classList.contains('show');
+    if (Toast.getInstance(element) || closed) continue;
+    const toast = new Toast(element);
+    toast.show();
+    // Retry on the next swap if a show.bs.toast listener cancelled the show
+    if (!toast.isShown()) toast.dispose();
   }
 }

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است