@@ -53,12 +53,15 @@ const Dropdown = (($) => {
53
53
MENULEFT : 'dropdown-menu-left'
54
54
}
55
55
56
+ // DROPDOWN_SHOWN exclude our other plugins which use .show class
56
57
const Selector = {
57
- DATA_TOGGLE : '[data-toggle="dropdown"]' ,
58
- FORM_CHILD : '.dropdown form' ,
59
- MENU : '.dropdown-menu' ,
60
- NAVBAR_NAV : '.navbar-nav' ,
61
- VISIBLE_ITEMS : '.dropdown-menu .dropdown-item:not(.disabled)'
58
+ DATA_TOGGLE : '[data-toggle="dropdown"]' ,
59
+ FORM_CHILD : '.dropdown form' ,
60
+ MENU : '.dropdown-menu' ,
61
+ NAVBAR_NAV : '.navbar-nav' ,
62
+ VISIBLE_ITEMS : `.dropdown-menu .dropdown-item:not(.${ ClassName . DISABLED } )` ,
63
+ ACTIVE_ITEMS : `.dropdown-item:not(.${ ClassName . DISABLED } )` ,
64
+ DROPDOWN_SHOWN : `.${ ClassName . SHOW } :not(.dropdown-menu):not(.alert):not(.collapse):not(.modal):not(.popover):not(.tab-pane):not(.tooltip)`
62
65
}
63
66
64
67
const AttachmentMap = {
@@ -414,7 +417,14 @@ const Dropdown = (($) => {
414
417
return
415
418
}
416
419
417
- const parent = Dropdown . _getParentFromElement ( this )
420
+ let parent = Dropdown . _getParentFromElement ( this )
421
+ let dropdown = $ ( parent ) . children ( Selector . DATA_TOGGLE ) [ 0 ]
422
+ if ( typeof dropdown === 'undefined' ) {
423
+ parent = $ ( parent ) . find ( Selector . DROPDOWN_SHOWN ) [ 0 ]
424
+ if ( typeof parent !== 'undefined' ) {
425
+ dropdown = $ ( parent ) . children ( Selector . DATA_TOGGLE ) [ 0 ]
426
+ }
427
+ }
418
428
const isActive = $ ( parent ) . hasClass ( ClassName . SHOW )
419
429
420
430
if ( ! isActive && ( event . which !== ESCAPE_KEYCODE || event . which !== SPACE_KEYCODE ) ||
@@ -429,7 +439,13 @@ const Dropdown = (($) => {
429
439
return
430
440
}
431
441
432
- const items = $ ( parent ) . find ( Selector . VISIBLE_ITEMS ) . get ( )
442
+ const context = $ ( dropdown ) . data ( DATA_KEY )
443
+ let items = null
444
+ if ( context . _config . container && Util . isElement ( context . _config . container ) ) {
445
+ items = $ ( context . _menu ) . find ( Selector . ACTIVE_ITEMS ) . get ( )
446
+ } else {
447
+ items = $ ( parent ) . find ( Selector . VISIBLE_ITEMS ) . get ( )
448
+ }
433
449
434
450
if ( ! items . length ) {
435
451
return
0 commit comments