From c0be90b95e7a6e4458574ed7406916adcc58e67e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Werlang?= Date: Thu, 6 Aug 2015 22:32:24 -0300 Subject: [PATCH] fix(uiSelect): typing goes on last focused component As scope() isn't available when debug info is disabled, use controller() to retrieve a controller from an element Fixes #872 --- src/uiSelectDirective.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uiSelectDirective.js b/src/uiSelectDirective.js index 3d391825c..0f537d196 100644 --- a/src/uiSelectDirective.js +++ b/src/uiSelectDirective.js @@ -149,8 +149,8 @@ uis.directive('uiSelect', if (!contains && !$select.clickTriggeredSelect) { //Will lose focus only with certain targets var focusableControls = ['input','button','textarea']; - var targetScope = angular.element(e.target).scope(); //To check if target is other ui-select - var skipFocusser = targetScope && targetScope.$select && targetScope.$select !== $select; //To check if target is other ui-select + var targetController = angular.element(e.target).controller('uiSelect'); //To check if target is other ui-select + var skipFocusser = targetController && targetController !== $select; //To check if target is other ui-select if (!skipFocusser) skipFocusser = ~focusableControls.indexOf(e.target.tagName.toLowerCase()); //Check if target is input, button or textarea $select.close(skipFocusser); scope.$digest();