1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-11 08:04:59 +02:00

Fix modal event-listeners during dismiss click (#36863)

ref: #36855
This commit is contained in:
GeoSot
2022-09-07 11:56:33 +03:00
committed by GitHub
parent 949456984a
commit 23fb7a7915
3 changed files with 20 additions and 12 deletions

View File

@@ -30,6 +30,7 @@ const EVENT_HIDDEN = `hidden${EVENT_KEY}`
const EVENT_SHOW = `show${EVENT_KEY}`
const EVENT_SHOWN = `shown${EVENT_KEY}`
const EVENT_RESIZE = `resize${EVENT_KEY}`
const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`
const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY}`
const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
@@ -222,18 +223,21 @@ class Modal extends BaseComponent {
})
EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => {
if (event.target !== event.currentTarget) { // click is inside modal-dialog
return
}
EventHandler.one(this._element, EVENT_CLICK_DISMISS, event2 => {
// a bad trick to segregate clicks that may start inside dialog but end outside, and avoid listen to scrollbar clicks
if (this._dialog.contains(event.target) || this._dialog.contains(event2.target)) {
return
}
if (this._config.backdrop === 'static') {
this._triggerBackdropTransition()
return
}
if (this._config.backdrop === 'static') {
this._triggerBackdropTransition()
return
}
if (this._config.backdrop) {
this.hide()
}
if (this._config.backdrop) {
this.hide()
}
})
})
}