Skip to content

Commit 71efd51

Browse files
author
Adam Bradley
committed
fix(popup): focus on first input
Closes #822
1 parent 879c61c commit 71efd51

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Diff for: js/angular/service/popup.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,16 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $docume
413413
}
414414

415415
function focusInputOrButton(element) {
416-
var inputs = element[0].querySelectorAll('input');
417-
if (!inputs.length) {
418-
inputs = element[0].querySelectorAll('button');
416+
var focusOn = element[0].querySelector('input[autofocus]');
417+
if (!focusOn) {
418+
focusOn = element[0].querySelector('input');
419+
if (!focusOn) {
420+
var buttons = element[0].querySelectorAll('button');
421+
focusOn = buttons[buttons.length-1];
422+
}
419423
}
420-
var last = inputs[inputs.length-1];
421-
if(last) {
422-
last.focus();
424+
if(focusOn) {
425+
focusOn.focus();
423426
}
424427
}
425428

0 commit comments

Comments
 (0)