summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/droplab
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-01-20 21:40:50 +0000
committerPhil Hughes <me@iamphill.com>2017-01-23 09:22:59 +0000
commit8e7929b874fbd8fe70c869eacde24ee3259e500c (patch)
treef838f900342598ac6e29cba3217d0741184c5edf /app/assets/javascripts/droplab
parentecf08ae1e65b2c95b71259864354b08e61335af9 (diff)
downloadgitlab-ce-8e7929b874fbd8fe70c869eacde24ee3259e500c.tar.gz
Checks if rendered count has changed rather than relying on key char
Diffstat (limited to 'app/assets/javascripts/droplab')
-rw-r--r--app/assets/javascripts/droplab/droplab.js1
-rw-r--r--app/assets/javascripts/droplab/droplab_filter.js22
2 files changed, 15 insertions, 8 deletions
diff --git a/app/assets/javascripts/droplab/droplab.js b/app/assets/javascripts/droplab/droplab.js
index 2e8c2e6f1e3..8b14191395b 100644
--- a/app/assets/javascripts/droplab/droplab.js
+++ b/app/assets/javascripts/droplab/droplab.js
@@ -615,7 +615,6 @@ require('./window')(function(w){
if (elOffsetTop > filterDropdownBottom) {
filterDropdownEl.scrollTop = elOffsetTop - filterDropdownBottom;
- console.log(filterDropdownEl.scrollTop);
}
}
}
diff --git a/app/assets/javascripts/droplab/droplab_filter.js b/app/assets/javascripts/droplab/droplab_filter.js
index b857fc68627..9b40a3f20a4 100644
--- a/app/assets/javascripts/droplab/droplab_filter.js
+++ b/app/assets/javascripts/droplab/droplab_filter.js
@@ -3,10 +3,11 @@
/* global droplab */
require('../window')(function(w){
- var charRegex = new RegExp('^.$', 'g');
w.droplabFilter = {
keydownWrapper: function(e){
+ var hiddenCount = 0;
+ var dataHiddenCount = 0;
var list = e.detail.hook.list;
var data = list.data;
var value = e.detail.hook.trigger.value.toLowerCase();
@@ -18,10 +19,6 @@ require('../window')(function(w){
return;
}
- if (!charRegex.test(e.detail.key)) {
- return;
- }
-
if (config && config.filterFunction && typeof config.filterFunction === 'function') {
filterFunction = config.filterFunction;
} else {
@@ -32,11 +29,22 @@ require('../window')(function(w){
};
}
+ dataHiddenCount = data.filter(function(o) {
+ return !o.droplab_hidden;
+ }).length;
+
matches = data.map(function(o) {
return filterFunction(o, value);
});
- list.render(matches);
- list.currentIndex = 0;
+
+ hiddenCount = matches.filter(function(o) {
+ return !o.droplab_hidden;
+ }).length;
+
+ if (dataHiddenCount !== hiddenCount) {
+ list.render(matches);
+ list.currentIndex = 0;
+ }
},
init: function init(hookInput) {