From b4787ba559e8b074c15436a6037747643ae265cf Mon Sep 17 00:00:00 2001 From: Marco Jantke Date: Wed, 6 Apr 2016 16:17:04 +0200 Subject: [PATCH] fix(ui-select): avoid dropdown flickering on search setting the opacity to 0 on each call to calculateDropdownPos brought the dropdown to flicker when you typed a search text. Now it is only doing this on initially opening the dropdown which avoids a flickering on the opening effect. --- src/uiSelectDirective.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/uiSelectDirective.js b/src/uiSelectDirective.js index 3032d8168..e0b906d8f 100644 --- a/src/uiSelectDirective.js +++ b/src/uiSelectDirective.js @@ -295,6 +295,13 @@ uis.directive('uiSelect', scope.$watch('$select.open', function() { if ($select.dropdownPosition === 'auto' || $select.dropdownPosition === 'up'){ + // Hide the dropdown to avoid flickering on initial opening + dropdown = angular.element(element).querySelectorAll('.ui-select-dropdown'); + + if (dropdown.length > 0) { + dropdown[0].style.opacity = 0; + } + scope.calculateDropdownPos(); } @@ -331,9 +338,6 @@ uis.directive('uiSelect', return; } - // Hide the dropdown so there is no flicker until $timeout is done executing. - dropdown[0].style.opacity = 0; - // Delay positioning the dropdown until all choices have been added so its height is correct. $timeout(function(){