]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Dropdown: use a combined selector to filter foreign not shown instances iteration...
authorGeoSot <geo.sotis@gmail.com>
Sat, 19 Feb 2022 14:16:51 +0000 (16:16 +0200)
committerGitHub <noreply@github.com>
Sat, 19 Feb 2022 14:16:51 +0000 (16:16 +0200)
js/src/dropdown.js

index 5635ec96ec6c495389ab8ef83e5d0f3f13b50ac1..4bb1379f576199de3d32a9395691864bc94bfb56 100644 (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 (