Skip to content

Commit

Permalink
feat(timepicker): add aria-label to input (#5604)
Browse files Browse the repository at this point in the history
Add aria label attribute to inputs in timepicker component
Add ability to set aria labels via CimpickerConfig

Close #4149

Co-authored-by: Dmitriy Shekhovtsov <valorkin@gmail.com>
  • Loading branch information
IraErshova and valorkin committed Jan 24, 2020
1 parent 70ed44a commit bbb2817
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 4 additions & 1 deletion demo/src/app/components/+timepicker/demos/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export function getTimepickerConfig(): TimepickerConfig {
readonlyInput: false,
mousewheel: true,
showMinutes: true,
showSeconds: false
showSeconds: false,
labelHours: 'Hours',
labelMinutes: 'Minutes',
labelSeconds: 'Seconds'
});
}

Expand Down
6 changes: 3 additions & 3 deletions src/timepicker/timepicker.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
(wheel)="prevDef($event);changeHours(hourStep * wheelSign($event), 'wheel')"
(keydown.ArrowUp)="changeHours(hourStep, 'key')"
(keydown.ArrowDown)="changeHours(-hourStep, 'key')"
(change)="updateHours($event.target.value)"></td>
(change)="updateHours($event.target.value)" [attr.aria-label]="labelHours"></td>
<!-- divider -->
<td *ngIf="showMinutes">&nbsp;:&nbsp;</td>
<!-- minutes -->
Expand All @@ -57,7 +57,7 @@
(wheel)="prevDef($event);changeMinutes(minuteStep * wheelSign($event), 'wheel')"
(keydown.ArrowUp)="changeMinutes(minuteStep, 'key')"
(keydown.ArrowDown)="changeMinutes(-minuteStep, 'key')"
(change)="updateMinutes($event.target.value)">
(change)="updateMinutes($event.target.value)" [attr.aria-label]="labelMinutes">
</td>
<!-- divider -->
<td *ngIf="showSeconds">&nbsp;:&nbsp;</td>
Expand All @@ -73,7 +73,7 @@
(wheel)="prevDef($event);changeSeconds(secondsStep * wheelSign($event), 'wheel')"
(keydown.ArrowUp)="changeSeconds(secondsStep, 'key')"
(keydown.ArrowDown)="changeSeconds(-secondsStep, 'key')"
(change)="updateSeconds($event.target.value)">
(change)="updateSeconds($event.target.value)" [attr.aria-label]="labelSeconds">
</td>
<!-- space between -->
<td *ngIf="showMeridian">&nbsp;&nbsp;&nbsp;</td>
Expand Down
5 changes: 5 additions & 0 deletions src/timepicker/timepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ export class TimepickerComponent
invalidMinutes = false;
invalidSeconds = false;

// aria-label variables
labelHours: string;
labelMinutes: string;
labelSeconds: string;

// time picker controls state
canIncrementHours: boolean;
canIncrementMinutes: boolean;
Expand Down
6 changes: 6 additions & 0 deletions src/timepicker/timepicker.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ export class TimepickerConfig {
minutesPlaceholder = 'MM';
/** placeholder for seconds field in timepicker */
secondsPlaceholder = 'SS';
/** hours aria label */
ariaLabelHours = 'hours';
/** minutes aria label */
ariaLabelMinutes = 'minutes';
/** seconds aria label */
ariaLabelSeconds = 'seconds';
}

0 comments on commit bbb2817

Please sign in to comment.