angularjs-dropdown-multiselect icon indicating copy to clipboard operation
angularjs-dropdown-multiselect copied to clipboard

memory leak

Open javid-p84 opened this issue 6 years ago • 0 comments

this piece has a memory leak where if user navigates through different pages , the hook to the click event does not die. So we will be adding a new event each time for each control. Especially for SPAs, this is a big issue. I have a simple fix for it and can make a PR if you let me.

if (scope.settings.closeOnBlur) { $document.on('click', function (e) { var target = e.target.parentElement; var parentFound = false;

                while (angular.isDefined(target) && target !== null && !parentFound) {
                    if (_.contains(target.className.split(' '), 'multiselect-parent') && !parentFound) {
                        if (target === $dropdownTrigger) {
                            parentFound = true;
                        }
                    }
                    target = target.parentElement;
                }

                if (!parentFound) {
                    scope.$apply(function () {
                        var bWasopen = false;
                        if (scope.open) bWasopen = true;
                        scope.open = false;
                        if (bWasopen) scope.externalEvents.onBlur();
                    });
                }
            });

        }

javid-p84 avatar Jan 16 '19 18:01 javid-p84