Skip to content

Commit 29e0c9d

Browse files
Dropdown — Change the selector to check the use of Popper (#33003)
* Create the popper instance first Make sure that popper instance has been created first and then apply the styling on the dropdown(menu) * Use `data-bs-popper` attibute to check popper Co-authored-by: XhmikosR <[email protected]>
1 parent 91d3da1 commit 29e0c9d

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

js/src/dropdown.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ class Dropdown extends BaseComponent {
181181
const popperConfig = this._getPopperConfig()
182182
const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false)
183183

184+
this._popper = Popper.createPopper(referenceElement, this._menu, popperConfig)
185+
184186
if (isDisplayStatic) {
185187
Manipulator.setDataAttribute(this._menu, 'popper', 'static')
186188
}
187-
188-
this._popper = Popper.createPopper(referenceElement, this._menu, popperConfig)
189189
}
190190

191191
// If this is a touch-enabled device we add extra

scss/_dropdown.scss

+4-7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
&[data-bs-popper] {
3636
left: 0;
37+
margin-top: $dropdown-spacer;
3738
}
3839
}
3940

@@ -73,7 +74,7 @@
7374
top: auto;
7475
bottom: 100%;
7576

76-
&.show:not([data-popper-placement]) {
77+
&[data-bs-popper] {
7778
margin-top: 0;
7879
margin-bottom: $dropdown-spacer;
7980
}
@@ -90,7 +91,7 @@
9091
right: auto;
9192
left: 100%;
9293

93-
&.show:not([data-popper-placement]) {
94+
&[data-bs-popper] {
9495
margin-top: 0;
9596
margin-left: $dropdown-spacer;
9697
}
@@ -110,7 +111,7 @@
110111
right: 100%;
111112
left: auto;
112113

113-
&.show:not([data-popper-placement]) {
114+
&[data-bs-popper] {
114115
margin-top: 0;
115116
margin-right: $dropdown-spacer;
116117
}
@@ -187,10 +188,6 @@
187188

188189
.dropdown-menu.show {
189190
display: block;
190-
191-
&:not([data-popper-placement]) {
192-
margin-top: $dropdown-spacer;
193-
}
194191
}
195192

196193
// Dropdown section headers

0 commit comments

Comments
 (0)