fix(aria): aria label/id updates

This commit is contained in:
Adam Bradley
2015-12-14 21:34:40 -06:00
parent 2a32711857
commit 7c8c56ee3e
7 changed files with 72 additions and 101 deletions

View File

@@ -3,6 +3,9 @@ import {Directive, Optional, ElementRef, Renderer} from 'angular2/core';
import {Config} from '../../config/config';
import {TextInput} from './text-input';
import {pointerCoord, hasPointerMoved} from '../../util/dom';
import {Form} from '../../util/form';
/**
* @name Label
* @description
@@ -38,15 +41,19 @@ export class Label {
constructor(
config: Config,
@Optional() container: TextInput,
private form: Form,
private elementRef: ElementRef,
private renderer: Renderer
) {
this.scrollAssist = config.get('scrollAssist');
if (!this.id) {
this.id = 'lbl-' + (++labelIds);
}
this.container = container;
container && container.registerLabel(this);
}
ngOnInit() {
if (!this.id) {
this.id = 'lbl-' + this.form.nextId();
}
this.container && this.container.registerLabel(this);
}
/**
@@ -87,5 +94,3 @@ export class Label {
}
}
let labelIds = -1;

View File

@@ -65,12 +65,20 @@
<textarea placeholder="Placeholder Text"></textarea>
</ion-input>
<ion-toggle>
Toggle
</ion-toggle>
<ion-input>
<ion-label>More Info:</ion-label>
<input placeholder="Placeholder Text" type="text">
<icon flag item-right></icon>
</ion-input>
<ion-checkbox>
Checkbox
</ion-checkbox>
<ion-input>
<ion-label>Score:</ion-label>
<input value="10" type="number">
@@ -100,95 +108,21 @@
Item
</ion-item>
</ion-list>
<!--
<ion-item>
Item
</ion-item>
<ion-list radio-group>
<ion-item>
Item
</ion-item>
<ion-list-header>
Radios
</ion-list-header>
<ion-item>
Item
</ion-item>
<ion-radio>
Radio 1
</ion-radio>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item>
<ion-item>
Item
</ion-item> -->
<ion-radio>
Radio 2
</ion-radio>
</ion-list>

View File

@@ -133,7 +133,7 @@ export class TextInput {
/**
* @private
*/
ngOnInit() {
ngAfterViewInit() {
if (this.input && this.label) {
// if there is an input and an label
// then give the label an ID