Accessibility in Blazor AutoComplete Component
29 Nov 20248 minutes to read
The Blazor AutoComplete component has been designed, keeping in mind the WAI-ARIA specifications, and applies the WAI-ARIA
roles, states, and properties along with keyboard support
. This component is characterized by complete keyboard interaction support and ARIA accessibility support that makes it easy for people who use assistive technologies (AT) or those who completely rely on keyboard navigation.
The Blazor AutoComplete 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 Blazor AutoComplete component is outlined below.
Accessibility Criteria | Compatibility |
---|---|
WCAG 2.2 Support | |
Section 508 Support | |
Screen Reader Support | |
Right-To-Left Support | |
Color Contrast | |
Mobile Device Support | |
Keyboard Navigation Support | |
Axe-core Accessibility Validation |
WAI-ARIA attributes
The Blazor AutoComplete component uses the combobox
role and each list item has an option
role. The following ARIA Attributes
denotes 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 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 |
---|---|
Focus | |
Alt + J | Focuses on the first component of the sample. |
Input Navigation | |
Alt + Down arrow | Opens the popup list. |
Alt + Up arrow | Closes the popup list. |
Tab | Focuses on the next TabIndex element on the page when the popup is closed. Otherwise, closes the popup list and remains the focus of the component. |
Shift + tab | Focuses on the previous TabIndex element on the page when the popup is closed. Otherwise, closes the popup list and remains the focus of the component. |
Selection | |
Enter | Selects the focused item, and when it is in open state, the popup list closes. Otherwise, toggles the popup list. |
Popup Navigation | |
Esc(Escape) | Closes the popup list when it is in an open state and the currently selected item remains the same. |
Down arrow | Selects the first item in the AutoComplete when no item is selected. Otherwise, selects the item next to the currently selected item. |
Up arrow | Selects the item previous to the currently selected one. |
Page down | Scrolls down to the next page and selects the first item when the popup list opens. |
Page up | Scrolls up to the previous page and selects the first item when the popup list opens. |
Home | Selects the first item. |
End | Selects the last item. |
NOTE
In the following sample, disable the AutoComplete component using t keys.
@using Syncfusion.Blazor.DropDowns
<SfAutoComplete TValue="string" TItem="Country" @ref="AutoObj" Placeholder="Select a country" Enabled="@enable" @onkeypress="@(e => KeyPressed(e))" DataSource="@LocalData">
<AutoCompleteFieldSettings Value="Name"></AutoCompleteFieldSettings>
</SfAutoComplete>
@code {
public SfAutoComplete<string, Country> AutoObj;
public bool enable { get; set; } = true ;
public class Country
{
public string Name { get; set; }
public string Code { get; set; }
}
List<Country> LocalData = new List<Country> {
new Country() { Name = "Australia", Code = "AU" },
new Country() { Name = "Bermuda", Code = "BM" },
new Country() { Name = "Canada", Code = "CA" },
new Country() { Name = "Cameroon", Code = "CM" },
new Country() { Name = "Denmark", Code = "DK" },
new Country() { Name = "France", Code = "FR" },
new Country() { Name = "Finland", Code = "FI" },
new Country() { Name = "Germany", Code = "DE" },
new Country() { Name = "Greenland", Code = "GL" },
new Country() { Name = "Hong Kong", Code = "HK" },
};
public void KeyPressed(KeyboardEventArgs args)
{
if (args.Key == "t")
{
enable = false;
}
}
}
Ensuring accessibility
The Blazor AutoComplete component’s accessibility levels are ensured through an axe-core software tool 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.