From ebe134bdd6a105f9c8267332ac2a42025909366a Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Mon, 14 Dec 2015 18:11:20 -0600 Subject: [PATCH] fix(input): multi-input case. Fixes #4778 --- js/angular/directive/input.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/js/angular/directive/input.js b/js/angular/directive/input.js index cb766220f8e..55a91d0439b 100644 --- a/js/angular/directive/input.js +++ b/js/angular/directive/input.js @@ -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(); + }; }] }; }]); @@ -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(); }); }); } @@ -113,8 +122,8 @@ IonicModule $element.attr('id', id); } - if (ionInputCtrl && ionInputCtrl.input) { - ionInputCtrl.input.setAttribute('aria-labelledby', id); + if (ionInputCtrl) { + ionInputCtrl.setInputAriaLabeledBy(id); } };