diff --git a/js/angular/service/popup.js b/js/angular/service/popup.js index 9a415bc0756..38f14083b65 100644 --- a/js/angular/service/popup.js +++ b/js/angular/service/popup.js @@ -321,7 +321,7 @@ function($animate, $ionicTemplateLoader, $ionicBackdrop, $log, $q, $timeout, $ro self.element.removeClass('popup-hidden'); self.element.addClass('popup-showing active'); ionic.DomUtil.centerElementByMarginTwice(self.element[0]); - focusLastButton(self.element); + focusInputOrButton(self.element); }); }; self.hide = function(callback) { @@ -404,11 +404,14 @@ function($animate, $ionicTemplateLoader, $ionicBackdrop, $log, $q, $timeout, $ro return resultPromise; } - function focusLastButton(element) { - var buttons = element[0].querySelectorAll('button'); - var lastButton = buttons[buttons.length-1]; - if(lastButton) { - lastButton.focus(); + function focusInputOrButton(element) { + var inputs = element[0].querySelectorAll('input'); + if (!inputs.length) { + inputs = element[0].querySelectorAll('button'); + } + var last = inputs[inputs.length-1]; + if(last) { + last.focus(); } }