1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05: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
}
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
}