From 9c0acf67eb9dbac23bff03c117b69fc919beb111 Mon Sep 17 00:00:00 2001 From: "josh_burson@intuit.com" Date: Mon, 25 Jan 2016 11:18:45 -0800 Subject: [PATCH] chore(dropdown): avoid toggling class on first load - Avoid toggling class on first load of directive Closes #5341 --- src/dropdown/dropdown.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dropdown/dropdown.js b/src/dropdown/dropdown.js index 1395963507..7a0a4b36b9 100644 --- a/src/dropdown/dropdown.js +++ b/src/dropdown/dropdown.js @@ -221,12 +221,15 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position']) } var openContainer = appendTo ? appendTo : $element; + var hasOpenClass = openContainer.hasClass(appendTo ? appendToOpenClass : openClass); - $animate[isOpen ? 'addClass' : 'removeClass'](openContainer, appendTo ? appendToOpenClass : openClass).then(function() { - if (angular.isDefined(isOpen) && isOpen !== wasOpen) { - toggleInvoker($scope, { open: !!isOpen }); - } - }); + if (hasOpenClass === !isOpen) { + $animate[isOpen ? 'addClass' : 'removeClass'](openContainer, appendTo ? appendToOpenClass : openClass).then(function() { + if (angular.isDefined(isOpen) && isOpen !== wasOpen) { + toggleInvoker($scope, { open: !!isOpen }); + } + }); + } if (isOpen) { if (self.dropdownMenuTemplateUrl) {