Skip to content

Commit

Permalink
fix(Datepicker): add aria role to Flatpickr dialog (#7465)
Browse files Browse the repository at this point in the history
Co-authored-by: Josh Black <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 5, 2021
1 parent 978fbdd commit 2c3b11b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/react/src/components/DatePicker/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ export default class DatePicker extends Component {
onValueUpdate: onHook,
});
this.addKeyboardEvents(this.cal);
this.addRoleAttributeToDialog();
}
}
}
Expand Down Expand Up @@ -386,6 +387,22 @@ export default class DatePicker extends Component {
}
};

/**
* Flatpickr's calendar dialog is not rendered in a landmark causing an
* error with IBM Equal Access Accessibility Checker so we add an aria
* role to the container div.
*/
addRoleAttributeToDialog = () => {
if (this.inputField) {
this.cal.calendarContainer.setAttribute('role', 'region');
// IBM EAAC requires an aria-label on a role='region'
this.cal.calendarContainer.setAttribute(
'aria-label',
'calendar-container'
);
}
};

addKeyboardEvents = (cal) => {
if (this.inputField) {
this.inputField.addEventListener('keydown', (e) => {
Expand Down

0 comments on commit 2c3b11b

Please sign in to comment.