Accessibility in Angular AutoComplete

31 Aug 20269 minutes to read

The AutoComplete component follows the WAI-ARIA specifications and applies the WAI-ARIA roles, states, and properties along with comprehensive keyboard support. It provides complete keyboard interaction and ARIA accessibility features that ensure usability for people who use assistive technologies (AT) or rely entirely on keyboard navigation.

The AutoComplete component adheres to 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 AutoComplete component is outlined below.

Accessibility Criteria Compatibility
WCAG 2.2 Support Intermediate
Section 508 Support Intermediate
Screen Reader Support Yes
Right-To-Left Support Yes
Color Contrast Yes
Mobile Device Support Yes
Keyboard Navigation Support Yes
Accessibility Checker Validation Yes
Axe-core Accessibility Validation Yes
Yes - All features of the component meet the requirement.
Intermediate - Some features of the component do not meet the requirement.
No - The component does not meet the requirement.

WAI-ARIA attributes

The AutoComplete component uses the combobox role and each list item has an option role. The following ARIA Attributes denote the AutoComplete state.

Property Functionalities
aria-haspopup Indicates whether the AutoComplete input element has a suggestion list or not.
aria-expanded Indicates whether the suggestion list has expanded or not.
aria-selected Indicates the selected option from the list.
aria-readonly Indicates the readonly state of the AutoComplete element.
aria-disabled Indicates whether the AutoComplete component is in a disabled state or not.
aria-activedescendent This attribute holds the ID of the active list item to focus its descendant child element.
aria-owns This attribute contains the ID of the suggestion list to indicate popup as a child element.
aria-autocomplete This attribute contains the ‘both’ to a list of options shows and the currently selected suggestion also shows inline.

Keyboard interaction

You can use the following key shortcuts to access the AutoComplete without interruptions.

Keyboard shortcuts Actions
Arrow Down In popup-hidden state, opens the suggestion list. In popup-open state, focuses the first item when no item is selected; otherwise, focuses the item next to the currently selected item.
Arrow Up In popup-hidden state, opens the suggestion list. In popup-open state, focuses the last item when no item is selected; otherwise, focuses the item previous to the currently selected one.
Page Down Scrolls down to the next page and focuses the first item when the popup list opens.
Page Up Scrolls up to the previous page and focuses the first item when the popup list is open.
Enter Selects the focused item and sets it in the AutoComplete component.
Tab Focuses on the next tab-indexed element when the popup is closed. Otherwise, closes the popup list and keeps focus on the component if it is in an open state.
Shift + Tab Focuses the previous tab-indexed element when the popup is closed. Otherwise, closes the popup list and keeps focus on the component if it is in an open state.
Alt + Down Opens the popup list.
Alt + Up In popup-hidden state, opens the popup list. In popup-open state, closes the popup list.
Esc Closes the popup list when it is in an open state, then removes the selection.
Home Moves the cursor to the beginning of the input.
End Moves the cursor to the end of the input.

In the sample below, focus the AutoComplete component using Alt + T keys.

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { AutoCompleteModule } from '@syncfusion/ej2-angular-dropdowns'
import { ButtonModule } from '@syncfusion/ej2-angular-buttons'




import { Component, HostListener, ViewChild } from '@angular/core';
import { AutoCompleteComponent } from '@syncfusion/ej2-angular-dropdowns';
@Component({
imports: [
        FormsModule, ReactiveFormsModule, AutoCompleteModule, ButtonModule
    ],


standalone: true,
    selector: 'app-root',
    // specifies the template string for the AutoComplete component
    template: `<ejs-autocomplete id='atcelement' #samples [dataSource]='sportsData' [fields]='fields' [placeholder]='text'></ejs-autocomplete>`
})
export class AppComponent {
    @ViewChild('samples')
    public sports?: AutoCompleteComponent;
    constructor() {
    }
    public sportsData:{ [key: string]: Object }[] = [
        { Id: 'Game1', Game: 'Badminton' },
        { Id: 'Game2', Game: 'Basketball' },
        { Id: 'Game3', Game: 'Cricket' },
        { Id: 'Game4', Game: 'Football' },
        { Id: 'Game5', Game: 'Golf' },
        { Id: 'Game6', Game: 'Hockey' },
        { Id: 'Game7', Game: 'Rugby' },
        { Id: 'Game8', Game: 'Snooker' },
        { Id: 'Game9', Game: 'Tennis' }
    ];
    // maps the appropriate column to fields property
    public fields: Object ={ value: 'Game' };
    //set the placeholder to AutoComplete input
    public text: string = "Find a game";
    @HostListener('document:keyup', ['$event'])
    handleKeyboardEvent(event: KeyboardEvent) {
        if (event.altKey && event.keyCode === 84 /* t */) {
            // press alt+t to focus the control.
            this.sports!.focusIn();
        }
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Ensuring accessibility

The AutoComplete component’s accessibility levels are ensured through an accessibility-checker and axe-core software tools during automated testing.

The accessibility compliance of the AutoComplete component is shown in the following sample. Open the sample in a new window to evaluate the accessibility of the AutoComplete component with accessibility tools.

See also