Accessibility in EJ2 TypeScript Datepicker control
24 Jan 20248 minutes to read
The DatePicker component followed the accessibility guidelines and standards, including ADA, Section 508, WCAG 2.2 standards, and WCAG roles that are commonly used to evaluate accessibility.
The accessibility compliance for the DatePicker component is outlined below.
WAI-ARIA attributes
The Web accessibility defines a way to make web content and web applications more accessible to disabled people. It especially helps the dynamic content change and advanced user interface controls developed with Ajax, HTML, JavaScript, and related technologies.
DatePicker provides built-in compliance with the WAI-ARIA specifications. WAI-ARIA
supports is achieved through the attributes like aria-expanded
, aria-disabled
, aria-activedescendant
applied to the input element.
To know about the accessibility of Calendar refer to the Calendar’s Accessibility section.
It helps to provide information about the widget for assistive technology to the disabled person in screen reader.
-
Aria-expanded: attributes indicates the state of a collapsible element.
-
Aria-disabled: attribute indicates the disabled state of this DatePicker component.
-
Aria-activedescendent: attribute helps in managing the current active child of the DatePicker component.
Keyboard Interaction
You can use the following keys to interact with the DatePicker. The component implements the keyboard navigation support by following the WAI-ARIA practices.
It supports the below list of shortcut keys.
Input Navigation
Before opening the popup, use the below list of keys to
control the popup element.
Press | To do this |
---|---|
Alt + Down Arrow | Opens the popup. |
Alt + Up Arrow | Closes the popup. |
Esc | closes the popup. |
Calendar Navigation
Use the below list of keys to navigate the Calendar after the popup has opened.
Press | To do this |
---|---|
Upper Arrow | Focus the previous week date. |
Down Arrow | Focus the next week date. |
Left Arrow | Focus the previous date. |
Right Arrow | Focus the next date. |
Home | Focus the first date in the month. |
End | Focus the last date in the month. |
Page Up | Focus the same date in the previous month. |
Page Down | Focus the same date in the next month. |
Enter | Select the currently focused date. |
Shift + Page Up | Focus the same date in the previous year. |
Shift + Page Down | Focus the same date in the previous year. |
Control + Upper Arrow | Moves into the inner level of view like month-year, year-decade |
Control + Down Arrow | Moves out from the depth level view like decade-year, year-month |
Control + Home | Focus the starting date in the current year. |
Control + End | Focus the ending date in the current year. |
To focus the DatePicker component use the
alt+t
keys.
import { DatePicker } from '@syncfusion/ej2-calendars';
// creates a DatePicker component
let datepickerObject: DatePicker = new DatePicker({
// sets the placeholder
placeholder: 'Enter date'
});
datepickerObject.appendTo('#element');
document.onkeyup = function (e) {
if (e.altKey && e.keyCode === 84 /* t */) {
// press alt+t to focus the component.
datepickerObject.element.focus();
}
};
<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 DatePicker control</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="styles.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-base/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-buttons/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-inputs/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-popups/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-calendars/styles/material.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<input id='element' type="text" />
</div>
</body>
</html>
Ensuring accessibility
The DatePicker component’s accessibility levels are ensured through an accessibility-checker and axe-core software tools during automated testing.
The accessibility compliance of the DatePicker component is shown in the following sample. Open the sample in a new window to evaluate the accessibility of the DatePicker component with accessibility tools.