mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-18 19:31:35 +02:00
Use the backdrop util in offcanvas, enforcing consistency (#33545)
* respect /share modal's backdrop functionality, keeping consistency * listen click events over backdrop (only) and trigger `hide()` without add/remove event tricks * achieve to hide foreign open offcanvas instances without glitches `if (allReadyOpen && allReadyOpen !== target)`, in case another is going to be open, when user clicks on trigger button
This commit is contained in:
@@ -158,6 +158,31 @@ describe('Backdrop', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('click callback', () => {
|
||||
it('it should execute callback on click', done => {
|
||||
const spy = jasmine.createSpy('spy')
|
||||
|
||||
const instance = new Backdrop({
|
||||
isVisible: true,
|
||||
isAnimated: false,
|
||||
clickCallback: () => spy()
|
||||
})
|
||||
const endTest = () => {
|
||||
setTimeout(() => {
|
||||
expect(spy).toHaveBeenCalled()
|
||||
done()
|
||||
}, 10)
|
||||
}
|
||||
|
||||
instance.show(() => {
|
||||
const clickEvent = document.createEvent('MouseEvents')
|
||||
clickEvent.initEvent('mousedown', true, true)
|
||||
document.querySelector(CLASS_BACKDROP).dispatchEvent(clickEvent)
|
||||
endTest()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('animation callbacks', () => {
|
||||
it('if it is animated, should show and hide backdrop after counting transition duration', done => {
|
||||
const instance = new Backdrop({
|
||||
|
Reference in New Issue
Block a user