Fix closing the alert when clicking on an action button

This commit is contained in:
Yohan Boniface 2023-05-31 18:40:52 +02:00
parent 5d6afdfb1b
commit cfe6bdf2a8

View file

@ -85,7 +85,7 @@ L.U.UI = L.Evented.extend({
L.DomUtil.addClass(this.parent, 'umap-alert')
L.DomUtil.addClass(this._alert, level_class)
const close = () => {
if (timeoutID !== this.ALERT_ID) {
if (timeoutID && timeoutID !== this.ALERT_ID) {
return
} // Another alert has been forced
this._alert.innerHTML = ''
@ -123,7 +123,7 @@ L.U.UI = L.Evented.extend({
L.DomEvent.on(el, 'click', L.DomEvent.stop).on(el, 'click', close, this)
if (action.callback)
L.DomEvent.on(el, 'click', () => {
action.callback.bind(action.callbackContext || this.map)()
action.callback.call(action.callbackContext || this.map)
close()
})
}