@@ -98,9 +98,9 @@ const Dropdown = (() => {
98
98
constructor ( element , config ) {
99
99
this . _element = element
100
100
this . _popper = null
101
+ this . _inNavbar = this . _detectNavbar ( )
101
102
this . _config = this . _getConfig ( config )
102
103
this . _menu = this . _getMenuElement ( )
103
- this . _inNavbar = this . _detectNavbar ( )
104
104
105
105
this . _addEventListeners ( )
106
106
}
@@ -154,7 +154,7 @@ const Dropdown = (() => {
154
154
element = parent
155
155
}
156
156
}
157
- if ( Util . isElement ( this . _config . container ) ) {
157
+ if ( Util . isElement ( this . _config . container ) && ! this . _inNavbar ) {
158
158
$ ( this . _config . container ) . append ( this . _menu )
159
159
}
160
160
this . _popper = new Popper ( element , this . _menu , this . _getPopperConfig ( ) )
@@ -219,13 +219,16 @@ const Dropdown = (() => {
219
219
this . constructor . DefaultType
220
220
)
221
221
222
- if ( Util . isElement ( config . container ) || typeof config . container === 'string' ) {
223
- // if it's a jQuery object or a collection of elements
224
- if ( typeof config . container . jquery === 'string' && typeof config . container [ 0 ] !== 'undefined' ) {
225
- config . container = config . container [ 0 ]
226
- } else if ( typeof config . container === 'string' ) {
227
- const tmpContainer = $ ( document ) . find ( config . container )
228
- config . container = typeof tmpContainer [ 0 ] !== 'undefined' ? tmpContainer [ 0 ] : false
222
+ // Only for dropdowns not in a navbar because we need Popper.js
223
+ if ( ! this . _inNavbar ) {
224
+ if ( Util . isElement ( config . container ) || typeof config . container === 'string' ) {
225
+ // if it's a jQuery object or a collection of elements
226
+ if ( typeof config . container . jquery === 'string' && typeof config . container [ 0 ] !== 'undefined' ) {
227
+ config . container = config . container [ 0 ]
228
+ } else if ( typeof config . container === 'string' ) {
229
+ const tmpContainer = $ ( document ) . find ( config . container )
230
+ config . container = typeof tmpContainer [ 0 ] !== 'undefined' ? tmpContainer [ 0 ] : false
231
+ }
229
232
}
230
233
}
231
234
@@ -352,7 +355,7 @@ const Dropdown = (() => {
352
355
}
353
356
354
357
toggles [ i ] . setAttribute ( 'aria-expanded' , 'false' )
355
- if ( Util . isElement ( context . _config . container ) ) {
358
+ if ( Util . isElement ( context . _config . container ) && ! context . _inNavbar ) {
356
359
$ ( parent ) . append ( context . _menu )
357
360
}
358
361
0 commit comments