Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoSot <geo.sotis@gmail.com>2021-10-10 16:39:47 +0300
committerXhmikosR <xhmikosr@gmail.com>2021-12-01 18:10:39 +0300
commit21e5618ba7007aa11b8a7751f1bbc1a9465dbab1 (patch)
tree51e10028cf218ef018abeb8a085cc3de9ef5ddba
parent0686fa00f04f5479753a32890dcae25b6c134e71 (diff)
Dropdown: rename vars
-rw-r--r--js/src/dropdown.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index c769ed5046..d5dfe2e20b 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -405,21 +405,23 @@ class Dropdown extends BaseComponent {
// - If trigger inside the menu => not a dropdown command
const isInput = /input|textarea/i.test(event.target.tagName)
- const eventKey = event.key
- if (!isInput && ![ARROW_UP_KEY, ARROW_DOWN_KEY, ESCAPE_KEY].includes(eventKey)) {
+ const isEscapeEvent = event.key === ESCAPE_KEY
+ const isUpOrDownEvent = [ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key)
+
+ if (!isInput && !(isUpOrDownEvent || isEscapeEvent)) {
return
}
if (isInput) {
// eslint-disable-next-line unicorn/no-lonely-if
- if (eventKey !== ESCAPE_KEY && (![ARROW_UP_KEY, ARROW_DOWN_KEY].includes(eventKey) || event.target.closest(SELECTOR_MENU))) {
+ if (!isEscapeEvent && (!isUpOrDownEvent || event.target.closest(SELECTOR_MENU))) {
return
}
}
const isActive = this.classList.contains(CLASS_NAME_SHOW)
- if (!isActive && event.key === ESCAPE_KEY) {
+ if (!isActive && isEscapeEvent) {
return
}
@@ -433,12 +435,12 @@ class Dropdown extends BaseComponent {
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 (isEscapeEvent) {
instance.hide()
return
}
- if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) {
+ if (isUpOrDownEvent) {
instance.show()
instance._selectMenuItem(event)
}