0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-29 11:24:18 +01:00

Update dropdown.js

minor refactoring
This commit is contained in:
GeoSot 2022-03-10 13:24:47 +02:00 committed by Mark Otto
parent 87da34014a
commit cfd2f3f778

View File

@ -404,25 +404,22 @@ class Dropdown extends BaseComponent {
}
event.preventDefault()
if (!isEscapeEvent) {
event.stopPropagation()
}
const getToggleButton = SelectorEngine.findOne(SELECTOR_DATA_TOGGLE, event.delegateTarget.parentNode)
const instance = Dropdown.getOrCreateInstance(getToggleButton)
if (isEscapeEvent) {
if (getToggleButton.classList.contains(CLASS_NAME_SHOW)) {
instance.hide()
getToggleButton.focus()
event.stopPropagation()
}
if (isUpOrDownEvent) {
event.stopPropagation()
instance.show()
instance._selectMenuItem(event)
return
}
instance.show()
instance._selectMenuItem(event)
if (instance._isShown()) { // else is escape and we check if it is shown
event.stopPropagation()
instance.hide()
getToggleButton.focus()
}
}
}