Skip to content

Commit

Permalink
fix(input): multi-input case. Fixes #4778
Browse files Browse the repository at this point in the history
  • Loading branch information
mlynch committed Dec 15, 2015
1 parent e49818a commit ebe134b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions js/angular/directive/input.js
Expand Up @@ -32,7 +32,15 @@ IonicModule
this.$scope = $scope;
this.$element = $element;

this.input = $element[0].querySelector('input,textarea');
this.setInputAriaLabeledBy = function(id) {
var inputs = $element[0].querySelectorAll('input,textarea');
inputs.length && inputs[0].setAttribute('aria-labelledby', id);
};

this.focus = function() {
var inputs = $element[0].querySelectorAll('input,textarea');
inputs.length && inputs[0].focus();
};
}]
};
}]);
Expand Down Expand Up @@ -79,12 +87,13 @@ IonicModule
$element.attr('id', id);
}

if (ionInputCtrl && ionInputCtrl.input) {
ionInputCtrl.input.setAttribute('aria-labelledby', id);
if (ionInputCtrl) {

ionInputCtrl.setInputAriaLabeledBy(id);

$element.on('click', function() {
$timeout(function() {
ionInputCtrl.input.focus();
ionInputCtrl.focus();
});
});
}
Expand Down Expand Up @@ -113,8 +122,8 @@ IonicModule
$element.attr('id', id);
}

if (ionInputCtrl && ionInputCtrl.input) {
ionInputCtrl.input.setAttribute('aria-labelledby', id);
if (ionInputCtrl) {
ionInputCtrl.setInputAriaLabeledBy(id);
}

};
Expand Down

0 comments on commit ebe134b

Please sign in to comment.