File tree 2 files changed +33
-1
lines changed
2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -409,10 +409,23 @@ class Modal {
409
409
return
410
410
}
411
411
412
+ const isModalOverflowing = this . _element . scrollHeight > document . documentElement . clientHeight
413
+
414
+ if ( ! isModalOverflowing ) {
415
+ this . _element . style . overflowY = 'hidden'
416
+ }
417
+
412
418
this . _element . classList . add ( CLASS_NAME_STATIC )
413
- const modalTransitionDuration = getTransitionDurationFromElement ( this . _element )
419
+ const modalTransitionDuration = getTransitionDurationFromElement ( this . _dialog )
420
+ EventHandler . off ( this . _element , TRANSITION_END )
414
421
EventHandler . one ( this . _element , TRANSITION_END , ( ) => {
415
422
this . _element . classList . remove ( CLASS_NAME_STATIC )
423
+ if ( ! isModalOverflowing ) {
424
+ EventHandler . one ( this . _element , TRANSITION_END , ( ) => {
425
+ this . _element . style . overflowY = ''
426
+ } )
427
+ emulateTransitionEnd ( this . _element , modalTransitionDuration )
428
+ }
416
429
} )
417
430
emulateTransitionEnd ( this . _element , modalTransitionDuration )
418
431
this . _element . focus ( )
Original file line number Diff line number Diff line change @@ -626,6 +626,25 @@ describe('Modal', () => {
626
626
modal . show ( )
627
627
} )
628
628
629
+ it ( 'should not overflow when clicking outside of modal-content if backdrop = static' , done => {
630
+ fixtureEl . innerHTML = '<div class="modal" data-backdrop="static"><div class="modal-dialog" style="transition-duration: 20ms;"></div></div>'
631
+
632
+ const modalEl = fixtureEl . querySelector ( '.modal' )
633
+ const modal = new Modal ( modalEl , {
634
+ backdrop : 'static'
635
+ } )
636
+
637
+ modalEl . addEventListener ( 'shown.bs.modal' , ( ) => {
638
+ modalEl . click ( )
639
+ setTimeout ( ( ) => {
640
+ expect ( modalEl . clientHeight === modalEl . scrollHeight ) . toEqual ( true )
641
+ done ( )
642
+ } , 20 )
643
+ } )
644
+
645
+ modal . show ( )
646
+ } )
647
+
629
648
it ( 'should not adjust the inline body padding when it does not overflow' , done => {
630
649
fixtureEl . innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
631
650
You can’t perform that action at this time.
0 commit comments