mirror of https://github.com/twbs/bootstrap.git
Dropdown: use destructured variables in `dataApyKeydownHandler`
This commit is contained in:
parent
c14fc989df
commit
c44d99f55c
|
@ -385,9 +385,10 @@ class Dropdown extends BaseComponent {
|
||||||
// - If key is not UP or DOWN => not a dropdown command
|
// - If key is not UP or DOWN => not a dropdown command
|
||||||
// - If trigger inside the menu => not a dropdown command
|
// - If trigger inside the menu => not a dropdown command
|
||||||
|
|
||||||
const isInput = /input|textarea/i.test(event.target.tagName)
|
const { target, key, delegateTarget } = event
|
||||||
const isEscapeEvent = event.key === ESCAPE_KEY
|
const isInput = /input|textarea/i.test(target.tagName)
|
||||||
const isUpOrDownEvent = [ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key)
|
const isEscapeEvent = key === ESCAPE_KEY
|
||||||
|
const isUpOrDownEvent = [ARROW_UP_KEY, ARROW_DOWN_KEY].includes(key)
|
||||||
|
|
||||||
if (!isInput && !(isUpOrDownEvent || isEscapeEvent)) {
|
if (!isInput && !(isUpOrDownEvent || isEscapeEvent)) {
|
||||||
return
|
return
|
||||||
|
@ -395,12 +396,12 @@ class Dropdown extends BaseComponent {
|
||||||
|
|
||||||
if (isInput && !isEscapeEvent) {
|
if (isInput && !isEscapeEvent) {
|
||||||
// eslint-disable-next-line unicorn/no-lonely-if
|
// eslint-disable-next-line unicorn/no-lonely-if
|
||||||
if (!isUpOrDownEvent || event.target.closest(SELECTOR_MENU)) {
|
if (!isUpOrDownEvent || target.closest(SELECTOR_MENU)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isActive = this.classList.contains(CLASS_NAME_SHOW)
|
const isActive = delegateTarget.classList.contains(CLASS_NAME_SHOW)
|
||||||
|
|
||||||
if (!isActive && isEscapeEvent) {
|
if (!isActive && isEscapeEvent) {
|
||||||
return
|
return
|
||||||
|
@ -413,7 +414,7 @@ class Dropdown extends BaseComponent {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const getToggleButton = SelectorEngine.findOne(SELECTOR_DATA_TOGGLE, event.delegateTarget.parentNode)
|
const getToggleButton = SelectorEngine.findOne(SELECTOR_DATA_TOGGLE, delegateTarget.parentNode)
|
||||||
const instance = Dropdown.getOrCreateInstance(getToggleButton)
|
const instance = Dropdown.getOrCreateInstance(getToggleButton)
|
||||||
|
|
||||||
if (isEscapeEvent) {
|
if (isEscapeEvent) {
|
||||||
|
|
Loading…
Reference in New Issue