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
path: root/js/src/util
diff options
context:
space:
mode:
authoralpadev <2838324+alpadev@users.noreply.github.com>2021-05-22 10:58:52 +0300
committerGitHub <noreply@github.com>2021-05-22 10:58:52 +0300
commitb39b665072a2d36914e741b2c11620323924be89 (patch)
treecaaf6f2f815901efff78bdca9796fb7a46d5f785 /js/src/util
parent803397554836dcba736eb50020ed3cea07b3a3ea (diff)
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 77bdc072fc..4d077b21f9 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