Skip to content

Commit

Permalink
feat(datepicker): indicate current day with aria-current
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinbuhmann committed Jul 27, 2022
1 parent 282f3f0 commit 388c065
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions projects/angular/src/forms/datepicker/day.spec.ts
Expand Up @@ -122,6 +122,20 @@ export default function () {
expect(context.clarityDirective.selectDay).toHaveBeenCalled();
});

it('sets arria-current on the button correctly', function () {
const button: HTMLButtonElement = context.clarityElement.children[0];

context.testComponent.dayView.isTodaysDate = true;

context.detectChanges();
expect(button.attributes['aria-current'].value).toBe('date');

context.testComponent.dayView.isTodaysDate = false;

context.detectChanges();
expect(button.attributes['aria-current'].value).toBe('false');
});

it('sets the correct value for the aria-label attribute', () => {
const dayBtn: HTMLButtonElement = context.clarityElement.children[0];
const dvm: DayViewModel = context.clarityDirective.dayView;
Expand Down
1 change: 1 addition & 0 deletions projects/angular/src/forms/datepicker/day.ts
Expand Up @@ -25,6 +25,7 @@ import { DateNavigationService } from './providers/date-navigation.service';
[attr.tabindex]="dayView.tabIndex"
(click)="selectDay()"
(focus)="onDayViewFocus()"
[attr.aria-current]="dayView.isTodaysDate ? 'date' : 'false'"
[attr.aria-label]="dayString"
[attr.aria-selected]="dayView.isSelected"
>
Expand Down

0 comments on commit 388c065

Please sign in to comment.