Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ebe134b

Browse files
committedDec 15, 2015
fix(input): multi-input case. Fixes #4778
1 parent e49818a commit ebe134b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed
 

‎js/angular/directive/input.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ IonicModule
3232
this.$scope = $scope;
3333
this.$element = $element;
3434

35-
this.input = $element[0].querySelector('input,textarea');
35+
this.setInputAriaLabeledBy = function(id) {
36+
var inputs = $element[0].querySelectorAll('input,textarea');
37+
inputs.length && inputs[0].setAttribute('aria-labelledby', id);
38+
};
39+
40+
this.focus = function() {
41+
var inputs = $element[0].querySelectorAll('input,textarea');
42+
inputs.length && inputs[0].focus();
43+
};
3644
}]
3745
};
3846
}]);
@@ -79,12 +87,13 @@ IonicModule
7987
$element.attr('id', id);
8088
}
8189

82-
if (ionInputCtrl && ionInputCtrl.input) {
83-
ionInputCtrl.input.setAttribute('aria-labelledby', id);
90+
if (ionInputCtrl) {
91+
92+
ionInputCtrl.setInputAriaLabeledBy(id);
8493

8594
$element.on('click', function() {
8695
$timeout(function() {
87-
ionInputCtrl.input.focus();
96+
ionInputCtrl.focus();
8897
});
8998
});
9099
}
@@ -113,8 +122,8 @@ IonicModule
113122
$element.attr('id', id);
114123
}
115124

116-
if (ionInputCtrl && ionInputCtrl.input) {
117-
ionInputCtrl.input.setAttribute('aria-labelledby', id);
125+
if (ionInputCtrl) {
126+
ionInputCtrl.setInputAriaLabeledBy(id);
118127
}
119128

120129
};

0 commit comments

Comments
 (0)
Please sign in to comment.