From 64306dab35fb62fbb28b3c04f6229356f102b0bb Mon Sep 17 00:00:00 2001 From: AParks Date: Wed, 2 Aug 2017 11:27:16 +1000 Subject: [PATCH] feat(typeahead): handles min-length of 0 keep typeahead popup open even when all input has been deleted. Still uses a default value of 1 for backward compatibility (when min-length is falsy but not === 0). see [#3600](https://github.com/angular-ui/bootstrap/pull/3600) and [commit](https://github.com/angular-ui/bootstrap/commit/a5a25141fc88e642b84e135796daaf77dc653273) --- bower.json | 2 +- ui-bootstrap-tpls.js | 10 +++++----- ui-bootstrap.js | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bower.json b/bower.json index ee4f11f..756f5b3 100644 --- a/bower.json +++ b/bower.json @@ -11,7 +11,7 @@ "license": "MIT", "ignore": [], "description": "Native AngularJS (Angular) directives for Bootstrap.", - "version": "0.12.1-7", + "version": "0.12.1-8", "main": ["./ui-bootstrap-tpls.js"], "dependencies": { "angular": ">=1 <1.3.0" diff --git a/ui-bootstrap-tpls.js b/ui-bootstrap-tpls.js index c3bb295..ad094a0 100644 --- a/ui-bootstrap-tpls.js +++ b/ui-bootstrap-tpls.js @@ -3555,9 +3555,9 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap //SUPPORTED ATTRIBUTES (OPTIONS) //minimal no of characters that needs to be entered before typeahead kicks-in - var minSearch = originalScope.$eval(attrs.typeaheadMinLength); - if (!minSearch && minSearch !== 0) { - minSearch = 1; + var minLength = originalScope.$eval(attrs.typeaheadMinLength); + if (!minLength && minLength !== 0) { + minLength = 1; } //minimal wait time after last character typed before typehead kicks-in @@ -3710,7 +3710,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap hasFocus = true; - if (inputValue && inputValue.length >= minSearch) { + if (minLength === 0 || inputValue && inputValue.length >= minLength) { if (waitTime > 0) { cancelPreviousTimeout(); scheduleSearchWithTimeout(inputValue); @@ -3825,7 +3825,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap element.bind('focus', function (evt) { hasFocus = true; - if (minSearch === 0 && !modelCtrl.$viewValue) { + if (minLength === 0 && !modelCtrl.$viewValue) { $timeout(function() { getMatchesAsync(modelCtrl.$viewValue, evt); }, 0); diff --git a/ui-bootstrap.js b/ui-bootstrap.js index ce23cda..3e71315 100644 --- a/ui-bootstrap.js +++ b/ui-bootstrap.js @@ -3554,9 +3554,9 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap //SUPPORTED ATTRIBUTES (OPTIONS) //minimal no of characters that needs to be entered before typeahead kicks-in - var minSearch = originalScope.$eval(attrs.typeaheadMinLength); - if (!minSearch && minSearch !== 0) { - minSearch = 1; + var minLength = originalScope.$eval(attrs.typeaheadMinLength); + if (!minLength && minLength !== 0) { + minLength = 1; } //minimal wait time after last character typed before typehead kicks-in @@ -3709,7 +3709,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap hasFocus = true; - if (inputValue && inputValue.length >= minSearch) { + if (minLength === 0 || inputValue && inputValue.length >= minLength) { if (waitTime > 0) { cancelPreviousTimeout(); scheduleSearchWithTimeout(inputValue); @@ -3824,7 +3824,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap element.bind('focus', function (evt) { hasFocus = true; - if (minSearch === 0 && !modelCtrl.$viewValue) { + if (minLength === 0 && !modelCtrl.$viewValue) { $timeout(function() { getMatchesAsync(modelCtrl.$viewValue, evt); }, 0);