Skip to content

Commit

Permalink
Dropdown.js: Use a better selector to avoid foreign not shown instanc…
Browse files Browse the repository at this point in the history
…es iteration
  • Loading branch information
GeoSot committed Dec 13, 2021
1 parent dcdf327 commit bf168f0
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions js/src/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const CLASS_NAME_DROPEND = 'dropend'
const CLASS_NAME_DROPSTART = 'dropstart'

const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)'
const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE}.${CLASS_NAME_SHOW}`
const SELECTOR_MENU = '.dropdown-menu'
const SELECTOR_NAVBAR = '.navbar'
const SELECTOR_NAVBAR_NAV = '.navbar-nav'
Expand Down Expand Up @@ -340,18 +341,14 @@ class Dropdown extends BaseComponent {
return
}

const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN)

for (const toggle of toggles) {
const context = Dropdown.getInstance(toggle)
if (!context || context._config.autoClose === false) {
continue
}

if (!context._isShown()) {
continue
}

const relatedTarget = {
relatedTarget: context._element
}
Expand Down

0 comments on commit bf168f0

Please sign in to comment.