From 82761ce78835129e7e37145752557a79e7232326 Mon Sep 17 00:00:00 2001 From: tymofieo Date: Tue, 24 Oct 2017 16:30:30 -0400 Subject: [PATCH 1/3] fix(uiSelectHeaderGroupSelectableDirective): do not issue error if feature is disabled, but directive exists on template --- src/uiSelectHeaderGroupSelectableDirective.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/uiSelectHeaderGroupSelectableDirective.js b/src/uiSelectHeaderGroupSelectableDirective.js index 826b7e08d..9b701a43d 100644 --- a/src/uiSelectHeaderGroupSelectableDirective.js +++ b/src/uiSelectHeaderGroupSelectableDirective.js @@ -20,7 +20,9 @@ uis.directive('uiSelectHeaderGroupSelectable', ['$timeout', function($timeout) { if ($select.multiple && $select.groups) { return $element.querySelectorAll('.ui-select-choices-group-label'); } else { - console.error('Use uiSelectHeaderGroupSelectable with no multiple uiSelect or without groupBy'); + if(isEnabled()){ + console.error('Use uiSelectHeaderGroupSelectable with no multiple uiSelect or without groupBy'); + } return []; } } From 4d328bca1a69314aa76c0670dc40e793a647852a Mon Sep 17 00:00:00 2001 From: tymofieo Date: Wed, 25 Oct 2017 17:07:04 -0400 Subject: [PATCH 2/3] fix(uiSelectHeaderGroupSelectableDirective): properly apply selectable feature after options list has changed --- src/uiSelectHeaderGroupSelectableDirective.js | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/uiSelectHeaderGroupSelectableDirective.js b/src/uiSelectHeaderGroupSelectableDirective.js index 9b701a43d..c9a4c36b7 100644 --- a/src/uiSelectHeaderGroupSelectableDirective.js +++ b/src/uiSelectHeaderGroupSelectableDirective.js @@ -29,25 +29,27 @@ uis.directive('uiSelectHeaderGroupSelectable', ['$timeout', function($timeout) { function enableClick() { if (isEnabled()) { - angular.forEach(getElements(), function(e) { - var element = angular.element(e); + $timeout(function() { + angular.forEach(getElements(), function (e) { + var element = angular.element(e); - // Check the onClick event is not already listen - if (!element.hasClass('ui-select-header-group-selectable')) { - element.addClass('ui-select-header-group-selectable'); + // Check the onClick event is not already listen + if (!element.hasClass('ui-select-header-group-selectable')) { + element.addClass('ui-select-header-group-selectable'); - element.on('click', function () { - if (isEnabled()) { - var group = $select.findGroupByName(element.text(), true); + element.on('click', function () { + if (isEnabled()) { + var group = $select.findGroupByName(element.text(), true); - angular.forEach(group.items, function(item) { - $timeout(function() { - $select.select(item, false, ' '); + angular.forEach(group.items, function (item) { + $timeout(function () { + $select.select(item, false, ' '); + }); }); - }); - } - }); - } + } + }); + } + }); }); } } @@ -71,9 +73,8 @@ uis.directive('uiSelectHeaderGroupSelectable', ['$timeout', function($timeout) { } }); - $scope.$watch('$select.groups', enableClick); $scope.$watch(function() { - return $select.selected && $select.selected.length ? $select.selected.length : -1; + return $select.groups && $select.groups.length ? $select.groups.length : -1; }, enableClick); } }; From f31944144e7a9bdc099080c279af42b7bfba0bed Mon Sep 17 00:00:00 2001 From: tymofieo Date: Thu, 26 Oct 2017 23:18:12 -0400 Subject: [PATCH 3/3] fix(uiSelectHeaderGroupSelectableDirective): do not add listener to group without header --- src/uiSelectHeaderGroupSelectableDirective.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uiSelectHeaderGroupSelectableDirective.js b/src/uiSelectHeaderGroupSelectableDirective.js index c9a4c36b7..9615d72cb 100644 --- a/src/uiSelectHeaderGroupSelectableDirective.js +++ b/src/uiSelectHeaderGroupSelectableDirective.js @@ -34,7 +34,7 @@ uis.directive('uiSelectHeaderGroupSelectable', ['$timeout', function($timeout) { var element = angular.element(e); // Check the onClick event is not already listen - if (!element.hasClass('ui-select-header-group-selectable')) { + if (element.text() && !element.hasClass('ui-select-header-group-selectable')) { element.addClass('ui-select-header-group-selectable'); element.on('click', function () {