1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-06 05:37:39 +02:00

Fix modal when is triggered by bs-toggle, to hide other open instances (#34701)

This commit is contained in:
GeoSot
2021-08-10 17:55:34 +03:00
committed by GitHub
parent 418fe8113e
commit 1e5e655670
3 changed files with 31 additions and 1 deletions

View File

@@ -63,6 +63,7 @@ const CLASS_NAME_FADE = 'fade'
const CLASS_NAME_SHOW = 'show'
const CLASS_NAME_STATIC = 'modal-static'
const OPEN_SELECTOR = '.modal.show'
const SELECTOR_DIALOG = '.modal-dialog'
const SELECTOR_MODAL_BODY = '.modal-body'
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="modal"]'
@@ -411,6 +412,12 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
})
})
// avoid conflict when clicking moddal toggler while another one is open
const allReadyOpen = SelectorEngine.findOne(OPEN_SELECTOR)
if (allReadyOpen) {
Modal.getInstance(allReadyOpen).hide()
}
const data = Modal.getOrCreateInstance(target)
data.toggle(this)