]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
make `dataApiKeydownHandler` to handle specific instance, avoiding extra manipulations
authorGeoSot <geo.sotis@gmail.com>
Thu, 8 Jul 2021 15:44:58 +0000 (18:44 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Thu, 22 Jul 2021 14:54:48 +0000 (17:54 +0300)
js/src/dropdown.js

index 60a27dbb0de64a8f99491436ff42a3a8f00613d5..52c5339faecce0f0e52361da0d1f5cf2a6a4339f 100644 (file)
@@ -449,20 +449,20 @@ class Dropdown extends BaseComponent {
       return
     }
 
-    const getToggleButton = () => this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0]
+    const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0]
+    const instance = Dropdown.getOrCreateInstance(getToggleButton)
 
     if (event.key === ESCAPE_KEY) {
-      getToggleButton().focus()
-      Dropdown.clearMenus()
+      instance.hide()
       return
     }
 
     if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) {
       if (!isActive) {
-        getToggleButton().click()
+        instance.show()
       }
 
-      Dropdown.getInstance(getToggleButton())._selectMenuItem(event)
+      instance._selectMenuItem(event)
       return
     }