mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-12 00:24:03 +02:00
fix: change dismiss handler, listening to key down, instead of click (#36401)
This commit is contained in:
@@ -641,9 +641,10 @@ describe('Modal', () => {
|
||||
|
||||
modalEl.addEventListener('shown.bs.modal', () => {
|
||||
const spy = spyOn(modal, '_queueCallback').and.callThrough()
|
||||
const mouseDown = createEvent('mousedown')
|
||||
|
||||
modalEl.click()
|
||||
modalEl.click()
|
||||
modalEl.dispatchEvent(mouseDown)
|
||||
modalEl.dispatchEvent(mouseDown)
|
||||
|
||||
setTimeout(() => {
|
||||
expect(spy).toHaveBeenCalledTimes(1)
|
||||
@@ -709,13 +710,19 @@ describe('Modal', () => {
|
||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||
|
||||
const modalEl = fixtureEl.querySelector('.modal')
|
||||
const dialogEl = modalEl.querySelector('.modal-dialog')
|
||||
const modal = new Modal(modalEl)
|
||||
modalEl.addEventListener('shown.bs.modal', () => {
|
||||
modalEl.click()
|
||||
})
|
||||
|
||||
modalEl.addEventListener('hidden.bs.modal', () => {
|
||||
expect(document.querySelector('.modal-backdrop')).toBeNull()
|
||||
spyOn(modal, 'hide')
|
||||
|
||||
modalEl.addEventListener('shown.bs.modal', () => {
|
||||
const mouseDown = createEvent('mousedown')
|
||||
|
||||
dialogEl.dispatchEvent(mouseDown)
|
||||
expect(modal.hide).not.toHaveBeenCalled()
|
||||
|
||||
modalEl.dispatchEvent(mouseDown)
|
||||
expect(modal.hide).toHaveBeenCalled()
|
||||
resolve()
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user