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

Fix prevented show event disables modals with fade class from being displayed again (#34085)

Fix modal, in case is faded, a prevented show event can cause show method to not  be executed again.
This commit is contained in:
alpadev
2021-05-24 17:52:36 +02:00
committed by GitHub
parent 136665903b
commit b513a19003
2 changed files with 35 additions and 6 deletions

View File

@@ -203,6 +203,33 @@ describe('Modal', () => {
modal.show()
})
it('should be shown after the first call to show() has been prevented while fading is enabled ', done => {
fixtureEl.innerHTML = '<div class="modal fade"><div class="modal-dialog"></div></div>'
const modalEl = fixtureEl.querySelector('.modal')
const modal = new Modal(modalEl)
let prevented = false
modalEl.addEventListener('show.bs.modal', e => {
if (!prevented) {
e.preventDefault()
prevented = true
setTimeout(() => {
modal.show()
})
}
})
modalEl.addEventListener('shown.bs.modal', () => {
expect(prevented).toBeTrue()
expect(modal._isAnimated()).toBeTrue()
done()
})
modal.show()
})
it('should set is transitioning if fade class is present', done => {
fixtureEl.innerHTML = '<div class="modal fade"><div class="modal-dialog"></div></div>'
@@ -210,7 +237,9 @@ describe('Modal', () => {
const modal = new Modal(modalEl)
modalEl.addEventListener('show.bs.modal', () => {
expect(modal._isTransitioning).toEqual(true)
setTimeout(() => {
expect(modal._isTransitioning).toEqual(true)
})
})
modalEl.addEventListener('shown.bs.modal', () => {