aboutsummaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorTanguy Krotoff <[email protected]>2020-04-15 17:59:31 +0200
committerXhmikosR <[email protected]>2020-04-17 18:22:15 +0300
commit7787f642b9abef8c079bb4594ac122731cbe18f8 (patch)
tree5505f2f06eab8268a403159268815400f29d67ea /js/src
parentd7f0f1aac92e70ca2324c64163d021c8f12ef948 (diff)
downloadbootstrap-7787f642b9abef8c079bb4594ac122731cbe18f8.tar.xz
bootstrap-7787f642b9abef8c079bb4594ac122731cbe18f8.zip
Fix crash when pressing ArrowUp the first time
Diffstat (limited to 'js/src')
-rw-r--r--js/src/dropdown.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index b1aa6d849..2fe707f15 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -479,7 +479,7 @@ class Dropdown {
return
}
- let index = items.indexOf(event.target) || 0
+ let index = items.indexOf(event.target)
if (event.key === ARROW_UP_KEY && index > 0) { // Up
index--
@@ -489,6 +489,9 @@ class Dropdown {
index++
}
+ // index is -1 if the first keydown is an ArrowUp
+ index = index === -1 ? 0 : index
+
items[index].focus()
}