Skip to content

Commit

Permalink
Enhanced filter for create option item in the dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
indrimuska committed Oct 11, 2017
1 parent 7d5ebe9 commit 6cc94ad
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/angular-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
marginTop = parseFloat(styles.marginTop || 0),
marginBottom = parseFloat(styles.marginBottom || 0);

if (!scope.filteredOptions.length) return;
if (!scope.filteredOptions.length || !option) return;

if (option.offsetTop + option.offsetHeight + marginBottom > dd.scrollTop + dd.offsetHeight)
scope.$evalAsync(function () {
Expand Down Expand Up @@ -438,10 +438,10 @@
}
// show create item option
if (scope.create) {
scope.showCreateOption = scope.create && scope.search && scope.filteredOptions.filter(function (option) {
return scope.getObjValue(option, scope.labelAttr).toLowerCase() == scope.search.toLowerCase();

}).length == 0;
scope.showCreateOption = scope.create && scope.search &&
filter(scope.filteredOptions, scope.search, function (actual, expected) {
return angular.isString(actual) && (actual || '').toLowerCase() == expected.toLowerCase();
}).length == 0;
if (scope.showCreateOption && scope.filteredOptions.length == 0 && scope.highlighted != -1) scope.highlighted = -1;
}
};
Expand Down

0 comments on commit 6cc94ad

Please sign in to comment.