Skip to content
This repository was archived by the owner on Dec 16, 2019. It is now read-only.

Commit fedbfaa

Browse files
committed
Fix slow performance when using closeOnBlur.
1 parent 8f751d8 commit fedbfaa

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

dist/angularjs-dropdown-multiselect.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/angularjs-dropdown-multiselect.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,24 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co
148148

149149
if ($scope.settings.closeOnBlur) {
150150
$document.on('click', function (e) {
151-
var target = e.target.parentElement;
152-
var parentFound = false;
153-
154-
while (angular.isDefined(target) && target !== null && !parentFound) {
155-
if (_.contains(target.className.split(' '), 'multiselect-parent') && !parentFound) {
156-
if(target === $dropdownTrigger) {
157-
parentFound = true;
151+
if ($scope.open) {
152+
var target = e.target.parentElement;
153+
var parentFound = false;
154+
155+
while (angular.isDefined(target) && target !== null && !parentFound) {
156+
if (_.contains(target.className.split(' '), 'multiselect-parent') && !parentFound) {
157+
if(target === $dropdownTrigger) {
158+
parentFound = true;
159+
}
158160
}
161+
target = target.parentElement;
159162
}
160-
target = target.parentElement;
161-
}
162163

163-
if (!parentFound) {
164-
$scope.$apply(function () {
165-
$scope.open = false;
166-
});
164+
if (!parentFound) {
165+
$scope.$apply(function () {
166+
$scope.open = false;
167+
});
168+
}
167169
}
168170
});
169171
}

0 commit comments

Comments
 (0)