@@ -54,11 +54,13 @@ const Dropdown = (($) => {
54
54
}
55
55
56
56
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)'
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(.${ ClassName . DISABLED } )` ,
62
+ ACTIVE_ITEMS : `.dropdown-item:not(.${ ClassName . DISABLED } )` ,
63
+ DROPDOWN_SHOWN : `.${ ClassName . SHOW } > [data-toggle="dropdown"]`
62
64
}
63
65
64
66
const AttachmentMap = {
@@ -414,7 +416,14 @@ const Dropdown = (($) => {
414
416
return
415
417
}
416
418
417
- const parent = Dropdown . _getParentFromElement ( this )
419
+ let parent = Dropdown . _getParentFromElement ( this )
420
+ let dropdown = $ ( parent ) . children ( Selector . DATA_TOGGLE ) [ 0 ]
421
+ if ( typeof dropdown === 'undefined' ) {
422
+ dropdown = $ ( parent ) . find ( Selector . DROPDOWN_SHOWN ) [ 0 ]
423
+ if ( typeof dropdown !== 'undefined' ) {
424
+ parent = dropdown . parentNode
425
+ }
426
+ }
418
427
const isActive = $ ( parent ) . hasClass ( ClassName . SHOW )
419
428
420
429
if ( ! isActive && ( event . which !== ESCAPE_KEYCODE || event . which !== SPACE_KEYCODE ) ||
@@ -429,7 +438,13 @@ const Dropdown = (($) => {
429
438
return
430
439
}
431
440
432
- const items = $ ( parent ) . find ( Selector . VISIBLE_ITEMS ) . get ( )
441
+ const context = $ ( dropdown ) . data ( DATA_KEY )
442
+ let items = null
443
+ if ( context . _config . container && Util . isElement ( context . _config . container ) ) {
444
+ items = $ ( context . _menu ) . children ( Selector . ACTIVE_ITEMS ) . get ( )
445
+ } else {
446
+ items = $ ( parent ) . find ( Selector . VISIBLE_ITEMS ) . get ( )
447
+ }
433
448
434
449
if ( ! items . length ) {
435
450
return
0 commit comments