Skip to content

Commit ef6b9aa

Browse files
mmalerbajelbourn
authored andcommitted
demo(input): make character counters aria-live=polite (#4600)
1 parent caee5a5 commit ef6b9aa

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

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

Lines changed: 22 additions & 11 deletions
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}">
4344
<md-hint align="end">
4445
<md-icon>mode_edit</md-icon>
45-
{{postalCode.value.length}} / 5
46+
<span aria-live="polite">{{postalCode.value.length}} / 5</span>
4647
</md-hint>
4748
</md-input-container>
4849
</td>
@@ -153,7 +154,9 @@ <h4>Input</h4>
153154
placeholder="Character count (100 max)"
154155
maxLength="100"
155156
value="Hello world. How are you?">
156-
<md-hint align="end">{{characterCountInputHintExample.value.length}} / 100</md-hint>
157+
<md-hint align="end" aria-live="polite">
158+
{{characterCountInputHintExample.value.length}} / 100
159+
</md-hint>
157160
</md-input-container>
158161
</p>
159162

@@ -164,7 +167,9 @@ <h4>Textarea</h4>
164167
#characterCountTextareaHintExample
165168
placeholder="Character count (100 max)"
166169
maxLength="100">Hello world. How are you?</textarea>
167-
<md-hint align="end">{{characterCountTextareaHintExample.value.length}} / 100</md-hint>
170+
<md-hint align="end" aria-live="polite">
171+
{{characterCountTextareaHintExample.value.length}} / 100
172+
</md-hint>
168173
</md-input-container>
169174
</p>
170175
</md-card-content>
@@ -195,7 +200,7 @@ <h4>Textarea</h4>
195200
<p>
196201
<md-input-container style="width: 100%">
197202
<input mdInput #input placeholder="Character count (100 max)" maxLength="100">
198-
<md-hint align="end">{{input.value.length}} / 100</md-hint>
203+
<md-hint align="end" aria-live="polite">{{input.value.length}} / 100</md-hint>
199204
</md-input-container>
200205
</p>
201206
<p>
@@ -218,16 +223,19 @@ <h4>Textarea</h4>
218223
<p>
219224
<md-input-container hintLabel="Hint label" style="width: 100%">
220225
<input mdInput #hintLabelWithCharCount placeholder="Show Hint Label With Character Count">
221-
<md-hint align="end">{{hintLabelWithCharCount.value.length}}</md-hint>
226+
<md-hint align="end" aria-live="polite">{{hintLabelWithCharCount.value.length}}</md-hint>
222227
</md-input-container>
223228
</p>
224229
<p>
225230
<md-input-container style="margin-bottom: 4em">
226231
<textarea mdInput #longHint placeholder="Enter text to count"></textarea>
227232
<md-hint>
228-
Enter some text to count how many characters are in it. The character count is shown on the right.
233+
Enter some text to count how many characters are in it. The character count is shown on
234+
the right.
235+
</md-hint>
236+
<md-hint align="end" style="white-space: nowrap" aria-live="polite">
237+
Length: {{longHint.value.length}}
229238
</md-hint>
230-
<md-hint align="end" style="white-space: nowrap">Length: {{longHint.value.length}}</md-hint>
231239
</md-input-container>
232240
</p>
233241
<p>
@@ -249,7 +257,8 @@ <h4>Textarea</h4>
249257
<md-input-container [hideRequiredMarker]="hideRequiredMarker" style="width: 300px">
250258
<input mdInput
251259
required
252-
[placeholder]="hideRequiredMarker ? 'Required Without Marker' : 'Required With Marker'">
260+
[placeholder]="hideRequiredMarker ?
261+
'Required Without Marker' : 'Required With Marker'">
253262
</md-input-container>
254263
</p>
255264
<p>
@@ -327,11 +336,13 @@ <h4>Textarea</h4>
327336
<md-card class="demo-card demo-basic">
328337
<md-toolbar color="primary">Forms</md-toolbar>
329338
<md-card-content>
330-
<md-input-container><input mdInput placeholder="reactive" [formControl]="formControl"></md-input-container>
339+
<md-input-container><input mdInput placeholder="reactive" [formControl]="formControl">
340+
</md-input-container>
331341
<md-input-container>
332342
<input mdInput placeholder="template" [(ngModel)]="model" required [disabled]="ctrlDisabled">
333343
</md-input-container>
334-
<button md-raised-button color="primary" (click)="formControl.enabled ? formControl.disable() : formControl.enable()">
344+
<button md-raised-button color="primary"
345+
(click)="formControl.enabled ? formControl.disable() : formControl.enable()">
335346
DISABLE REACTIVE CTRL
336347
</button>
337348
<button md-raised-button color="primary" (click)="ctrlDisabled = !ctrlDisabled">

0 commit comments

Comments
 (0)