Skip to content

Commit

Permalink
Remove the toasts when they are autohidden
Browse files Browse the repository at this point in the history
Fixes: #1430

Signed-off-by: Aurélien Bompard <[email protected]>
  • Loading branch information
abompard committed Oct 11, 2024
1 parent aa16a0c commit 284299c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions news/1430.bug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the toasts when they are autohidden
11 changes: 9 additions & 2 deletions noggin/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@
</script>
<script nonce="{{ csp_nonce() }}">
const toastElList = document.querySelectorAll('.toast')
const toastList = [...toastElList].map(toastEl => new bootstrap.Toast(toastEl))
toastList.forEach(toast => toast.show());
toastElList.forEach((element) => {
const toast = new bootstrap.Toast(element);
toast.show();
// Remove the element when it's autohidden
// https://github.com/fedora-infra/noggin/issues/1430
element.addEventListener('hidden.bs.toast', () => {
element.remove();
})
});
</script>
{% endif %}
{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion noggin/themes/fas/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
// https://getbootstrap.com/docs/5.0/components/popovers/#example-enable-popovers-everywhere
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl, {html: true})
return new bootstrap.Popover(popoverTriggerEl, {html: true})
})
})
</script>
Expand Down

0 comments on commit 284299c

Please sign in to comment.