Dropdown: use a combined selector to filter foreign not shown instances iteration (#35766)

This commit is contained in:
GeoSot 2022-02-19 16:16:51 +02:00 committed by GitHub
parent 4b17868fb4
commit 353ad45b4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 6 deletions

View File

@ -50,6 +50,7 @@ const CLASS_NAME_DROPEND = 'dropend'
const CLASS_NAME_DROPSTART = 'dropstart'
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="dropdown"]'
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'
@ -341,18 +342,14 @@ class Dropdown extends BaseComponent {
return
}
const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN)
for (const toggle of toggles) {
for (const toggle of openToggles) {
const context = Dropdown.getInstance(toggle)
if (!context || context._config.autoClose === false) {
continue
}
if (!context._isShown()) {
continue
}
const composedPath = event.composedPath()
const isMenuTarget = composedPath.includes(context._menu)
if (