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

document click event when closeOnBlur #260

Open
@bogdanim36

Description

@bogdanim36

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);
                    }
                }
            };

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions