Skip to content

Commit f8a7492

Browse files
authored
Merge pull request #3178 from Akshat55/datepicker-jaws
fix: set role attribute to application & add button role to days
2 parents 5072769 + 8e46e95 commit f8a7492

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/datepicker/datepicker.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,11 @@ export class DatePicker implements
510510

511511
const calendarContainer = this.flatpickrInstance.calendarContainer;
512512
const dayElement = calendarContainer && calendarContainer.querySelector(".flatpickr-day[tabindex]");
513+
const selectedDateElem = calendarContainer && calendarContainer.querySelector('.selected');
514+
const todayDateElem = calendarContainer && calendarContainer.querySelector('.today');
513515

514516
if (dayElement) {
515-
dayElement.focus();
517+
(todayDateElem || selectedDateElem || dayElement).focus();
516518

517519
// If the user manually inputs a value into the date field and presses arrow down,
518520
// datepicker input onchange will be triggered when focus is removed from it and
@@ -591,6 +593,7 @@ export class DatePicker implements
591593

592594
// add day classes and special case the "today" element based on `this.value`
593595
Array.from(dayContainer).forEach(element => {
596+
element.setAttribute('role', 'button');
594597
element.classList.add("cds--date-picker__day");
595598
if (!this.value) {
596599
return;
@@ -606,7 +609,7 @@ export class DatePicker implements
606609
protected updateAttributes() {
607610
const calendarContainer = document.querySelectorAll(".flatpickr-calendar");
608611
Array.from(calendarContainer).forEach(calendar => {
609-
calendar.setAttribute("role", "region");
612+
calendar.setAttribute("role", "application");
610613
calendar.setAttribute("aria-label", this.ariaLabel);
611614
});
612615
}

0 commit comments

Comments
 (0)