Skip to content

Commit cb5e077

Browse files
committed
demo(input): make character counters aria-live=polite
1 parent 05dbb90 commit cb5e077

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

src/demo-app/input/input-demo.html

+34-14
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@
3939
</td>
4040
<td>
4141
<md-input-container class="demo-full-width">
42-
<input mdInput #postalCode maxLength="5" placeholder="Postal Code" value="94043">
42+
<input mdInput #postalCode maxLength="5" placeholder="Postal Code" value="94043"
43+
pattern="[0-9]{5}" aria-controls="zipChars">
4344
<md-hint align="end">
4445
<md-icon>mode_edit</md-icon>
45-
{{postalCode.value.length}} / 5
46+
<span id="zipChars" aria-live="polite">{{postalCode.value.length}} / 5</span>
4647
</md-hint>
4748
</md-input-container>
4849
</td>
@@ -152,8 +153,11 @@ <h4>Input</h4>
152153
#characterCountInputHintExample
153154
placeholder="Character count (100 max)"
154155
maxLength="100"
156+
aria-controls="helloInputChars"
155157
value="Hello world. How are you?">
156-
<md-hint align="end">{{characterCountInputHintExample.value.length}} / 100</md-hint>
158+
<md-hint align="end" id="helloInputChars" aria-live="polite">
159+
{{characterCountInputHintExample.value.length}} / 100
160+
</md-hint>
157161
</md-input-container>
158162
</p>
159163

@@ -163,8 +167,11 @@ <h4>Textarea</h4>
163167
<textarea mdInput
164168
#characterCountTextareaHintExample
165169
placeholder="Character count (100 max)"
170+
aria-controls="helloTextareaChars"
166171
maxLength="100">Hello world. How are you?</textarea>
167-
<md-hint align="end">{{characterCountTextareaHintExample.value.length}} / 100</md-hint>
172+
<md-hint align="end" id="helloTextareaChars" aria-live="polite">
173+
{{characterCountTextareaHintExample.value.length}} / 100
174+
</md-hint>
168175
</md-input-container>
169176
</p>
170177
</md-card-content>
@@ -194,8 +201,11 @@ <h4>Textarea</h4>
194201
</p>
195202
<p>
196203
<md-input-container style="width: 100%">
197-
<input mdInput #input placeholder="Character count (100 max)" maxLength="100">
198-
<md-hint align="end">{{input.value.length}} / 100</md-hint>
204+
<input mdInput #input placeholder="Character count (100 max)" maxLength="100"
205+
aria-controls="inputChars">
206+
<md-hint align="end" id="inputChars" aria-live="polite">
207+
{{input.value.length}} / 100
208+
</md-hint>
199209
</md-input-container>
200210
</p>
201211
<p>
@@ -217,17 +227,24 @@ <h4>Textarea</h4>
217227
</p>
218228
<p>
219229
<md-input-container hintLabel="Hint label" style="width: 100%">
220-
<input mdInput #hintLabelWithCharCount placeholder="Show Hint Label With Character Count">
221-
<md-hint align="end">{{hintLabelWithCharCount.value.length}}</md-hint>
230+
<input mdInput #hintLabelWithCharCount placeholder="Show Hint Label With Character Count"
231+
aria-controls="inputChars2">
232+
<md-hint align="end" id="inputChars2" aria-live="polite">
233+
{{hintLabelWithCharCount.value.length}}
234+
</md-hint>
222235
</md-input-container>
223236
</p>
224237
<p>
225238
<md-input-container style="margin-bottom: 4em">
226-
<textarea mdInput #longHint placeholder="Enter text to count"></textarea>
239+
<textarea mdInput #longHint placeholder="Enter text to count"
240+
aria-controls="counterChars"></textarea>
227241
<md-hint>
228-
Enter some text to count how many characters are in it. The character count is shown on the right.
242+
Enter some text to count how many characters are in it. The character count is shown on
243+
the right.
244+
</md-hint>
245+
<md-hint align="end" style="white-space: nowrap" id="counterChars" aria-live="polite">
246+
Length: {{longHint.value.length}}
229247
</md-hint>
230-
<md-hint align="end" style="white-space: nowrap">Length: {{longHint.value.length}}</md-hint>
231248
</md-input-container>
232249
</p>
233250
<p>
@@ -249,7 +266,8 @@ <h4>Textarea</h4>
249266
<md-input-container [hideRequiredMarker]="hideRequiredMarker" style="width: 300px">
250267
<input mdInput
251268
required
252-
[placeholder]="hideRequiredMarker ? 'Required Without Marker' : 'Required With Marker'">
269+
[placeholder]="hideRequiredMarker ?
270+
'Required Without Marker' : 'Required With Marker'">
253271
</md-input-container>
254272
</p>
255273
<p>
@@ -327,11 +345,13 @@ <h4>Textarea</h4>
327345
<md-card class="demo-card demo-basic">
328346
<md-toolbar color="primary">Forms</md-toolbar>
329347
<md-card-content>
330-
<md-input-container><input mdInput placeholder="reactive" [formControl]="formControl"></md-input-container>
348+
<md-input-container><input mdInput placeholder="reactive" [formControl]="formControl">
349+
</md-input-container>
331350
<md-input-container>
332351
<input mdInput placeholder="template" [(ngModel)]="model" required [disabled]="ctrlDisabled">
333352
</md-input-container>
334-
<button md-raised-button color="primary" (click)="formControl.enabled ? formControl.disable() : formControl.enable()">
353+
<button md-raised-button color="primary"
354+
(click)="formControl.enabled ? formControl.disable() : formControl.enable()">
335355
DISABLE REACTIVE CTRL
336356
</button>
337357
<button md-raised-button color="primary" (click)="ctrlDisabled = !ctrlDisabled">

0 commit comments

Comments
 (0)