1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-08 14:46:34 +02:00

Fix crash when pressing ArrowUp the first time

This commit is contained in:
Tanguy Krotoff
2020-04-15 17:59:31 +02:00
committed by XhmikosR
parent d7f0f1aac9
commit 7787f642b9
2 changed files with 32 additions and 1 deletions

View File

@@ -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()
}