Checks if rendered count has changed rather than relying on key char

This commit is contained in:
Phil Hughes 2017-01-20 21:40:50 +00:00
parent ecf08ae1e6
commit 8e7929b874
2 changed files with 15 additions and 8 deletions

View file

@ -615,7 +615,6 @@ require('./window')(function(w){
if (elOffsetTop > filterDropdownBottom) { if (elOffsetTop > filterDropdownBottom) {
filterDropdownEl.scrollTop = elOffsetTop - filterDropdownBottom; filterDropdownEl.scrollTop = elOffsetTop - filterDropdownBottom;
console.log(filterDropdownEl.scrollTop);
} }
} }
} }

View file

@ -3,10 +3,11 @@
/* global droplab */ /* global droplab */
require('../window')(function(w){ require('../window')(function(w){
var charRegex = new RegExp('^.$', 'g');
w.droplabFilter = { w.droplabFilter = {
keydownWrapper: function(e){ keydownWrapper: function(e){
var hiddenCount = 0;
var dataHiddenCount = 0;
var list = e.detail.hook.list; var list = e.detail.hook.list;
var data = list.data; var data = list.data;
var value = e.detail.hook.trigger.value.toLowerCase(); var value = e.detail.hook.trigger.value.toLowerCase();
@ -18,10 +19,6 @@ require('../window')(function(w){
return; return;
} }
if (!charRegex.test(e.detail.key)) {
return;
}
if (config && config.filterFunction && typeof config.filterFunction === 'function') { if (config && config.filterFunction && typeof config.filterFunction === 'function') {
filterFunction = config.filterFunction; filterFunction = config.filterFunction;
} else { } else {
@ -32,11 +29,22 @@ require('../window')(function(w){
}; };
} }
dataHiddenCount = data.filter(function(o) {
return !o.droplab_hidden;
}).length;
matches = data.map(function(o) { matches = data.map(function(o) {
return filterFunction(o, value); 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) { init: function init(hookInput) {