diff --git a/package.json b/package.json index a235570613..89ea61762f 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "author": "https://github.com/angular-ui/bootstrap/graphs/contributors", - "name": "angular-ui-bootstrap", - "version": "2.1.3-SNAPSHOT", - "homepage": "http://angular-ui.github.io/bootstrap/", + "name": "angular-bootstrap-fork", + "version": "2.1.6", + "homepage": "https://github.com/benkow/angular-bootstrap-fork", "dependencies": {}, "directories": { "lib": "src/" @@ -19,7 +19,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/angular-ui/bootstrap.git" + "url": "https://github.com/benkow/angular-bootstrap-fork.git" }, "devDependencies": { "angular": "1.5.8", diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 126fd1fd47..d0a9e4a63b 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -407,13 +407,17 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1; scope.$digest(); target = popUpEl[0].querySelectorAll('.uib-typeahead-match')[scope.activeIdx]; - target.parentNode.scrollTop = target.offsetTop; + if(angular.isDefined(target)){ + target.parentNode.scrollTop = target.offsetTop; + } break; case 40: // down arrow scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length; scope.$digest(); target = popUpEl[0].querySelectorAll('.uib-typeahead-match')[scope.activeIdx]; - target.parentNode.scrollTop = target.offsetTop; + if(angular.isDefined(target)){ + target.parentNode.scrollTop = target.offsetTop; + } break; default: if (shouldSelect) { @@ -440,6 +444,12 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap }); element.bind('blur', function(evt) { + + /*console.log("scope.matches.length", scope.matches.length); + console.log("isSelectOnBlur", isSelectOnBlur); + console.log("scope.activeIdx", scope.activeIdx); + console.log("selected", selected);*/ + if (isSelectOnBlur && scope.matches.length && scope.activeIdx !== -1 && !selected) { selected = true; scope.$apply(function() { @@ -447,11 +457,17 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap $$debounce(function() { scope.select(scope.activeIdx, evt); }, scope.debounceUpdate.blur); - } else { + } + else { scope.select(scope.activeIdx, evt); } }); } + //reset popup (close) if focus is lost, e.g. due to form-arrow-click on iPhone + else if (!isSelectOnBlur && scope.matches.length && scope.activeIdx === -1) { + resetMatches(); + } + if (!isEditable && modelCtrl.$error.editable) { modelCtrl.$setViewValue(); scope.$apply(function() { @@ -461,6 +477,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap }); element.val(''); } + hasFocus = false; selected = false; });