aboutsummaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2022-09-07 11:56:33 +0300
committerGitHub <[email protected]>2022-09-07 11:56:33 +0300
commit23fb7a79156d1ea4ce2ab5713debbbc251b4e22f (patch)
tree47960992a48a2c16ff3e872e2636140fd84f28cb /js/src
parent949456984aa21536afd35eddf7ea38b3648830a3 (diff)
downloadbootstrap-23fb7a79156d1ea4ce2ab5713debbbc251b4e22f.tar.xz
bootstrap-23fb7a79156d1ea4ce2ab5713debbbc251b4e22f.zip
Fix modal event-listeners during dismiss click (#36863)
ref: #36855
Diffstat (limited to 'js/src')
-rw-r--r--js/src/modal.js28
1 files changed, 16 insertions, 12 deletions
diff --git a/js/src/modal.js b/js/src/modal.js
index 3e990e7cc..1f281e2a3 100644
--- a/js/src/modal.js
+++ b/js/src/modal.js
@@ -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
- }
-
- if (this._config.backdrop === 'static') {
- this._triggerBackdropTransition()
- return
- }
-
- if (this._config.backdrop) {
- this.hide()
- }
+ 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) {
+ this.hide()
+ }
+ })
})
}