1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-06 21:56:42 +02:00

make dataApiKeydownHandler to handle specific instance, avoiding extra manipulations

This commit is contained in:
GeoSot
2021-07-08 18:44:58 +03:00
committed by XhmikosR
parent 9916191311
commit e85a6ed77c

View File

@@ -449,20 +449,20 @@ class Dropdown extends BaseComponent {
return 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) { if (event.key === ESCAPE_KEY) {
getToggleButton().focus() instance.hide()
Dropdown.clearMenus()
return return
} }
if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) { if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) {
if (!isActive) { if (!isActive) {
getToggleButton().click() instance.show()
} }
Dropdown.getInstance(getToggleButton())._selectMenuItem(event) instance._selectMenuItem(event)
return return
} }