From 62e76648dc1c9598edef0d047f436f346e9e8876 Mon Sep 17 00:00:00 2001 From: Adrian Lee Date: Tue, 24 Jun 2014 22:14:51 -0700 Subject: [PATCH] fix(macAutocomplete): Fixed not able to select item when clicking on dropdown Fixes #174 --- src/directives/autocomplete.coffee | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/directives/autocomplete.coffee b/src/directives/autocomplete.coffee index e84730c..d77f4e0 100644 --- a/src/directives/autocomplete.coffee +++ b/src/directives/autocomplete.coffee @@ -148,7 +148,8 @@ angular.module("Mac").directive "macAutocomplete", [ Create a click handler function to make sure directive is unbinding the correct handler ### - clickHandler = -> reset(true) + clickHandler = -> + $scope.$apply -> hide() ### @function @@ -174,9 +175,13 @@ angular.module("Mac").directive "macAutocomplete", [ @description Resetting autocomplete ### - reset = (invokeApply = false) -> + reset = -> + $menuScope.items.length = 0 + + hide() + + hide = -> $animate.leave menuEl, -> - $menuScope.items = [] $menuScope.index = 0 # Clear menu element inline style @@ -187,8 +192,6 @@ angular.module("Mac").directive "macAutocomplete", [ element.unbind "blur", clickHandler - $scope.$apply() if invokeApply - return ### @@ -327,7 +330,7 @@ angular.module("Mac").directive "macAutocomplete", [ when keys.ESCAPE $scope.$apply -> - reset() + hide() event.preventDefault()