File tree Expand file tree Collapse file tree 3 files changed +22
-14
lines changed Expand file tree Collapse file tree 3 files changed +22
-14
lines changed Original file line number Diff line number Diff line change 3434 },
3535 {
3636 "path" : " ./dist/js/bootstrap.bundle.js" ,
37- "maxSize" : " 43.0 kB"
37+ "maxSize" : " 43.25 kB"
3838 },
3939 {
4040 "path" : " ./dist/js/bootstrap.bundle.min.js" ,
5050 },
5151 {
5252 "path" : " ./dist/js/bootstrap.js" ,
53- "maxSize" : " 28.5 kB"
53+ "maxSize" : " 28.75 kB"
5454 },
5555 {
5656 "path" : " ./dist/js/bootstrap.min.js" ,
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ const EVENT_HIDDEN = `hidden${EVENT_KEY}`
3030const EVENT_SHOW = `show${ EVENT_KEY } `
3131const EVENT_SHOWN = `shown${ EVENT_KEY } `
3232const EVENT_RESIZE = `resize${ EVENT_KEY } `
33+ const EVENT_CLICK_DISMISS = `click.dismiss${ EVENT_KEY } `
3334const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${ EVENT_KEY } `
3435const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${ EVENT_KEY } `
3536const EVENT_CLICK_DATA_API = `click${ EVENT_KEY } ${ DATA_API_KEY } `
@@ -222,18 +223,21 @@ class Modal extends BaseComponent {
222223 } )
223224
224225 EventHandler . on ( this . _element , EVENT_MOUSEDOWN_DISMISS , event => {
225- if ( event . target !== event . currentTarget ) { // click is inside modal-dialog
226- return
227- }
228-
229- if ( this . _config . backdrop === 'static' ) {
230- this . _triggerBackdropTransition ( )
231- return
232- }
233-
234- if ( this . _config . backdrop ) {
235- this . hide ( )
236- }
226+ EventHandler . one ( this . _element , EVENT_CLICK_DISMISS , event2 => {
227+ // a bad trick to segregate clicks that may start inside dialog but end outside, and avoid listen to scrollbar clicks
228+ if ( this . _dialog . contains ( event . target ) || this . _dialog . contains ( event2 . target ) ) {
229+ return
230+ }
231+
232+ if ( this . _config . backdrop === 'static' ) {
233+ this . _triggerBackdropTransition ( )
234+ return
235+ }
236+
237+ if ( this . _config . backdrop ) {
238+ this . hide ( )
239+ }
240+ } )
237241 } )
238242 }
239243
Original file line number Diff line number Diff line change @@ -644,7 +644,9 @@ describe('Modal', () => {
644644 const mouseDown = createEvent ( 'mousedown' )
645645
646646 modalEl . dispatchEvent ( mouseDown )
647+ modalEl . click ( )
647648 modalEl . dispatchEvent ( mouseDown )
649+ modalEl . click ( )
648650
649651 setTimeout ( ( ) => {
650652 expect ( spy ) . toHaveBeenCalledTimes ( 1 )
@@ -719,9 +721,11 @@ describe('Modal', () => {
719721 const mouseDown = createEvent ( 'mousedown' )
720722
721723 dialogEl . dispatchEvent ( mouseDown )
724+ modalEl . click ( )
722725 expect ( spy ) . not . toHaveBeenCalled ( )
723726
724727 modalEl . dispatchEvent ( mouseDown )
728+ modalEl . click ( )
725729 expect ( spy ) . toHaveBeenCalled ( )
726730 resolve ( )
727731 } )
You can’t perform that action at this time.
0 commit comments