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

document click event when closeOnBlur

Open bogdanim36 opened this issue 9 years ago • 4 comments

The document click event is not removed on element distroy. In fact, document click event must registred on open event si unregistred on destroy and close. And code look something like this:

           var documentClick = function (e) {
                console.log("documetn click");
                var target = e.target.parentElement;
                var parentFound = false;

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

                if (!parentFound) {
                    $scope.$apply(function () {
                        $scope.open = false;
                        $document.off('click', documentClick);
                    });
                }
            };
            $element.on("$destroy", function () {
                $document.off('click', documentClick);
            });

            $scope.toggleDropdown = function () {
                $scope.open = !$scope.open;
                if ($scope.settings.closeOnBlur) {
                    if ($scope.open) {
                        $document.on('click', documentClick);

                    } else {
                         $document.off('click', documentClick);
                    }
                }
            };

bogdanim36 avatar Aug 28 '16 11:08 bogdanim36

This issue is high on my prio list

pkempenaers avatar Mar 19 '17 20:03 pkempenaers

any update on this issue? @pkempenaers

lzynihao avatar Aug 21 '17 10:08 lzynihao

ok, I saw the new code, thanks.@pkempenaers

lzynihao avatar Aug 21 '17 11:08 lzynihao

Where's the new code, I didn't see code to unregister the event even in the latest version? @lzynihao @pkempenaers

dragonsoft-cara avatar Jan 04 '18 08:01 dragonsoft-cara