From bcd69ccb47182cdf2e9334988c4f4d9edd017110 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 31 Jan 2025 16:42:38 +0100 Subject: [PATCH] fix: clear previous alert timeout when opening a new alert Otherwise, when an infinite alert replace an alert with a finite duration, this first alert timeout will close the second alert. Co-authored-by: David Larlet --- umap/static/umap/js/components/alerts/alert.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/components/alerts/alert.js b/umap/static/umap/js/components/alerts/alert.js index 517b7992..d47fc83d 100644 --- a/umap/static/umap/js/components/alerts/alert.js +++ b/umap/static/umap/js/components/alerts/alert.js @@ -57,8 +57,11 @@ class uMapAlert extends uMapElement { this.container.dataset.duration = duration this.element.textContent = message this.setAttribute('open', 'open') + if (this._timeoutId) { + clearTimeout(this._timeoutId) + } if (Number.isFinite(duration)) { - setTimeout(() => { + this._timeoutId = setTimeout(() => { this._hide() }, duration) }