mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 11:52:38 +02:00
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 <david@larlet.fr>
This commit is contained in:
parent
3e9982c8cb
commit
bcd69ccb47
1 changed files with 4 additions and 1 deletions
|
@ -57,8 +57,11 @@ class uMapAlert extends uMapElement {
|
||||||
this.container.dataset.duration = duration
|
this.container.dataset.duration = duration
|
||||||
this.element.textContent = message
|
this.element.textContent = message
|
||||||
this.setAttribute('open', 'open')
|
this.setAttribute('open', 'open')
|
||||||
|
if (this._timeoutId) {
|
||||||
|
clearTimeout(this._timeoutId)
|
||||||
|
}
|
||||||
if (Number.isFinite(duration)) {
|
if (Number.isFinite(duration)) {
|
||||||
setTimeout(() => {
|
this._timeoutId = setTimeout(() => {
|
||||||
this._hide()
|
this._hide()
|
||||||
}, duration)
|
}, duration)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue