From a618365a434a4c527016a615d76b9f7695246287 Mon Sep 17 00:00:00 2001 From: Corwynt Date: Mon, 8 Feb 2016 09:01:07 +0100 Subject: [PATCH 1/4] Added maybeLeaveEditMode `maybeLeaveEditMode` replaces the `leaveEditMode` event handler used in the ng-blur event. It prevents the default event execution if the clicked element is a typeahed suggestion. --- src/angular-advanced-searchbox.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/angular-advanced-searchbox.js b/src/angular-advanced-searchbox.js index c128b17..c6baba6 100644 --- a/src/angular-advanced-searchbox.js +++ b/src/angular-advanced-searchbox.js @@ -90,7 +90,16 @@ angular.module('angular-advanced-searchbox', []) $scope.$emit('advanced-searchbox:enteredEditMode', searchParam); }; - + /** + * Fix to prevent ignoring of the Click-Selection of a typeahead Element + **/ + $scope.maybeLeaveEditMode = function (e, index) { + if(e.relatedTarget.parentElement.id.indexOf("typeahead")!=-1){ + return false; + }else{ + return $scope.leaveEditMode(e,index); + } + } $scope.leaveEditMode = function(e, index) { if (index === undefined) return; From 2481bd62859cae0923769e4111097b4ec7bbb074 Mon Sep 17 00:00:00 2001 From: Corwynt Date: Mon, 8 Feb 2016 09:04:12 +0100 Subject: [PATCH 2/4] maybeLeaveEditMode Template changes changed `leaveEditMode`to `maybeLeaveEditMode` --- src/angular-advanced-searchbox.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/angular-advanced-searchbox.html b/src/angular-advanced-searchbox.html index 2452429..2b66397 100644 --- a/src/angular-advanced-searchbox.html +++ b/src/angular-advanced-searchbox.html @@ -16,7 +16,7 @@ nit-auto-size-input nit-set-focus="searchParam.editMode" ng-keydown="keydown($event, $index)" - ng-blur="leaveEditMode($event, $index)" + ng-blur="maybeLeaveEditMode($event, $index)" ng-show="searchParam.editMode" ng-change="searchParam.restrictToSuggestedValues !== true ? searchParamValueChanged(searchParam) : null" ng-model="searchParam.value" @@ -46,4 +46,4 @@ {{parametersLabel}}: {{param.name}} - \ No newline at end of file + From ffc0938d64379ecdb45dfa422d8f43989c270f0e Mon Sep 17 00:00:00 2001 From: Corwynt Date: Mon, 8 Feb 2016 09:39:48 +0100 Subject: [PATCH 3/4] Fixed clicking on body element Clicking on body lead to an error --- src/angular-advanced-searchbox.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/angular-advanced-searchbox.js b/src/angular-advanced-searchbox.js index c6baba6..1327e9f 100644 --- a/src/angular-advanced-searchbox.js +++ b/src/angular-advanced-searchbox.js @@ -94,12 +94,12 @@ angular.module('angular-advanced-searchbox', []) * Fix to prevent ignoring of the Click-Selection of a typeahead Element **/ $scope.maybeLeaveEditMode = function (e, index) { - if(e.relatedTarget.parentElement.id.indexOf("typeahead")!=-1){ + if(e.relatedTarget!=null && e.relatedTarget.parentElement.id.indexOf("typeahead")!=-1){ return false; }else{ return $scope.leaveEditMode(e,index); } - } + }; $scope.leaveEditMode = function(e, index) { if (index === undefined) return; From e9b1144b2f4556ca3db4f070d2f1c4125f06eeb1 Mon Sep 17 00:00:00 2001 From: Corwynt Date: Mon, 8 Feb 2016 09:43:17 +0100 Subject: [PATCH 4/4] travis ci fix --- src/angular-advanced-searchbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/angular-advanced-searchbox.js b/src/angular-advanced-searchbox.js index 1327e9f..b48c8b6 100644 --- a/src/angular-advanced-searchbox.js +++ b/src/angular-advanced-searchbox.js @@ -94,7 +94,7 @@ angular.module('angular-advanced-searchbox', []) * Fix to prevent ignoring of the Click-Selection of a typeahead Element **/ $scope.maybeLeaveEditMode = function (e, index) { - if(e.relatedTarget!=null && e.relatedTarget.parentElement.id.indexOf("typeahead")!=-1){ + if(e.relatedTarget !== null && e.relatedTarget.parentElement.id.indexOf("typeahead")!=-1){ return false; }else{ return $scope.leaveEditMode(e,index);