diff options
| author | Tanguy Krotoff <[email protected]> | 2020-04-15 17:59:31 +0200 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2020-04-17 18:22:15 +0300 |
| commit | 7787f642b9abef8c079bb4594ac122731cbe18f8 (patch) | |
| tree | 5505f2f06eab8268a403159268815400f29d67ea /js/src/dropdown.js | |
| parent | d7f0f1aac92e70ca2324c64163d021c8f12ef948 (diff) | |
| download | bootstrap-7787f642b9abef8c079bb4594ac122731cbe18f8.tar.xz bootstrap-7787f642b9abef8c079bb4594ac122731cbe18f8.zip | |
Fix crash when pressing ArrowUp the first time
Diffstat (limited to 'js/src/dropdown.js')
| -rw-r--r-- | js/src/dropdown.js | 5 |
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() } |
