aboutsummaryrefslogtreecommitdiff
path: root/js/src/util
diff options
context:
space:
mode:
authoralpadev <[email protected]>2021-05-22 09:58:52 +0200
committerGitHub <[email protected]>2021-05-22 10:58:52 +0300
commitb39b665072a2d36914e741b2c11620323924be89 (patch)
treecaaf6f2f815901efff78bdca9796fb7a46d5f785 /js/src/util
parent803397554836dcba736eb50020ed3cea07b3a3ea (diff)
downloadbootstrap-b39b665072a2d36914e741b2c11620323924be89.tar.xz
bootstrap-b39b665072a2d36914e741b2c11620323924be89.zip
Automatically select an item in the dropdown when using arrow keys (#34052)
Diffstat (limited to 'js/src/util')
-rw-r--r--js/src/util/index.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/js/src/util/index.js b/js/src/util/index.js
index 77bdc072f..4d077b21f 100644
--- a/js/src/util/index.js
+++ b/js/src/util/index.js
@@ -264,9 +264,9 @@ const execute = callback => {
const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
let index = list.indexOf(activeElement)
- // if the element does not exist in the list initialize it as the first element
+ // if the element does not exist in the list return an element depending on the direction and if cycle is allowed
if (index === -1) {
- return list[0]
+ return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0]
}
const listLength = list.length