diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index 316b5e736..e39ef1961 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -300,14 +300,15 @@ class Dropdown extends BaseComponent {
name: 'applyCustomStyles',
enabled: true,
phase: 'afterWrite',
- fn: () => {
+ fn: ({ state }) => {
this._menu.style.removeProperty('position')
const initialPosition = getComputedStyle(this._menu).position
if (this._config.display === 'static' || initialPosition === 'static') {
- // this._menu.style.position = 'static'
this._menu.style.removeProperty('margin')
this._menu.style.removeProperty('transform')
Manipulator.setDataAttribute(this._menu, 'popper', 'static') // todo:v6 remove?
+ } else {
+ this._menu.style.position = state.styles.popper.position
}
}
}]
diff --git a/js/tests/unit/dropdown.spec.js b/js/tests/unit/dropdown.spec.js
index 56ac4ff49..ec87159d6 100644
--- a/js/tests/unit/dropdown.spec.js
+++ b/js/tests/unit/dropdown.spec.js
@@ -1071,7 +1071,7 @@ describe('Dropdown', () => {
})
describe('update', () => {
- it('should call Popper and detect navbar on update', () => {
+ it('should call Popper on update', () => {
fixtureEl.innerHTML = [
'
',
'
',
@@ -1089,12 +1089,10 @@ describe('Dropdown', () => {
expect(dropdown._popper).not.toBeNull()
const spyUpdate = spyOn(dropdown._popper, 'update')
- const spyDetect = spyOn(dropdown, '_detectNavbar')
dropdown.update()
expect(spyUpdate).toHaveBeenCalled()
- expect(spyDetect).toHaveBeenCalled()
})
it('should just detect navbar on update', () => {
@@ -1163,33 +1161,6 @@ describe('Dropdown', () => {
})
})
- it('should not use "static" Popper in navbar', () => {
- return new Promise(resolve => {
- fixtureEl.innerHTML = [
- '
'
- ].join('')
-
- const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]')
- const dropdownMenu = fixtureEl.querySelector('.dropdown-menu')
- const dropdown = new Dropdown(btnDropdown)
-
- btnDropdown.addEventListener('shown.bs.dropdown', () => {
- expect(dropdown._popper).not.toBeNull()
- expect(dropdownMenu.getAttribute('data-bs-popper')).toEqual('static')
- resolve()
- })
-
- dropdown.show()
- })
- })
-
it('should not collapse the dropdown when clicking a select option nested in the dropdown', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = [
@@ -1233,13 +1204,13 @@ describe('Dropdown', () => {
})
})
- it('should manage bs attribute `data-bs-popper`="static" when dropdown is in navbar', () => {
+ it('should manage bs attribute `data-bs-popper`="static" when dropdown has position=static', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = [
'