Skip to content

Commit

Permalink
fix(popup): focus on first input
Browse files Browse the repository at this point in the history
Closes #822
  • Loading branch information
Adam Bradley committed Jun 3, 2014
1 parent 879c61c commit 71efd51
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions js/angular/service/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,16 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $docume
}

function focusInputOrButton(element) {
var inputs = element[0].querySelectorAll('input');
if (!inputs.length) {
inputs = element[0].querySelectorAll('button');
var focusOn = element[0].querySelector('input[autofocus]');
if (!focusOn) {
focusOn = element[0].querySelector('input');
if (!focusOn) {
var buttons = element[0].querySelectorAll('button');
focusOn = buttons[buttons.length-1];
}
}
var last = inputs[inputs.length-1];
if(last) {
last.focus();
if(focusOn) {
focusOn.focus();
}
}

Expand Down

0 comments on commit 71efd51

Please sign in to comment.