Add timeout to the blur event of tag-complete

The blur event was causing elements to be hidden
before the ng-click event was triggered, making impossible
to click and select one element. Add a timeout to defer
the blur event a bit, in order for click events to
be processed properly.

Change-Id: I88fb60d4ba0f17e4078f827555bd51d3fe7a4d1b
This commit is contained in:
Yolanda Robla 2014-11-18 16:56:36 +01:00
parent 1c81b8a7cc
commit 98d6496d0f

View File

@ -19,7 +19,7 @@
* set of source data, and restricts inputs to items in that list.
*/
angular.module('sb.util').directive('tagComplete',
function ($q, $parse, $rootScope, $position, typeaheadParser) {
function ($q, $parse, $rootScope, $position, typeaheadParser, $timeout) {
'use strict';
var HOT_KEYS = [9, 13, 27, 38, 40];
@ -165,12 +165,14 @@ angular.module('sb.util').directive('tagComplete',
* Blur when the input gets blurred.
*/
$input.on('blur', function () {
resetMatches();
$scope.newTagName = '';
$scope.hasFocus = false;
if (!$rootScope.$$phase) {
$scope.$digest();
}
$timeout(function() {
resetMatches();
$scope.newTagName = '';
$scope.hasFocus = false;
if (!$rootScope.$$phase) {
$scope.$digest();
}
}, 200);
});
/**