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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user