Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-01-20 17:20:29 +0300
committerPhil Hughes <me@iamphill.com>2017-01-23 12:22:24 +0300
commit3680612a5f9b7e457f429c8900214d590d2e73ff (patch)
tree52bf43471549cdbbc479c0825d5a758a9167d6db /app/assets/javascripts
parent90058cf4eaa4f1064a25334e1b3540ab12ed2dfa (diff)
Fixed currentIndex being shared across dropdowns
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/droplab/droplab.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/assets/javascripts/droplab/droplab.js b/app/assets/javascripts/droplab/droplab.js
index c79f0230951..4d10d4e004d 100644
--- a/app/assets/javascripts/droplab/droplab.js
+++ b/app/assets/javascripts/droplab/droplab.js
@@ -58,6 +58,7 @@ var CustomEvent = require('./custom_event_polyfill');
var utils = require('./utils');
var DropDown = function(list) {
+ this.currentIndex = 0;
this.hidden = true;
this.list = list;
this.items = [];
@@ -576,7 +577,7 @@ require('./window')(function(w){
var isUpArrow = false;
var isDownArrow = false;
var removeHighlight = function removeHighlight(list) {
- var listItems = list.list.querySelectorAll('li');
+ var listItems = list.list.querySelectorAll('li:not(.divider)');
for(var i = 0; i < listItems.length; i++) {
listItems[i].classList.remove('dropdown-active');
}
@@ -589,7 +590,10 @@ require('./window')(function(w){
if(!listItems[currentIndex-1]){
currentIndex = currentIndex-1;
}
- listItems[currentIndex-1].classList.add('dropdown-active');
+
+ if (listItems[currentIndex-1]) {
+ listItems[currentIndex-1].classList.add('dropdown-active');
+ }
}
};
@@ -617,6 +621,8 @@ require('./window')(function(w){
var keydown = function keydown(e){
var typedOn = e.target;
+ var dropdown = e.detail.hook.list;
+ currentIndex = dropdown.currentIndex;
isUpArrow = false;
isDownArrow = false;
@@ -649,6 +655,7 @@ require('./window')(function(w){
if(isDownArrow){ currentIndex++; }
if(currentIndex < 0){ currentIndex = 0; }
setMenuForArrows(e.detail.hook.list);
+ dropdown.currentIndex = currentIndex;
};
w.addEventListener('mousedown.dl', mousedown);