Search results

Accessibility

The 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.

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, selects the first item when no item selected else selects the item next to the currently selected item.
Arrow Up In popup hidden state, opens the suggestion list. In popup open state, selects the last item when no item selected else selects the item previous to the currently selected one.
Page Down Scrolls down to the next page and selects the first item when popup list opens.
Page Up Scrolls up to previous page and select the first item when popup list open.
Enter Selects the focused item and set to AutoComplete component.
Tab Focuses on the next tab indexed element when the popup is closed. Otherwise, closes the popup list and remains the focus in component suppose 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 remains the focus in component suppose 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(Escape) Closes the popup list when it is in an open state then remove the selection.
Home Cursor moves to before of first character in input.
End Cursor moves to next of last character in input.

In the below sample, focus the AutoComplete component using alt+t keys.

tagHelper
GameList.cs
accessibility.cs
<div class="control-wrapper">
    <div id="default" style='padding-top:75px;margin:0 auto;width:250px;'>
        <ejs-autocomplete id="country" dataSource="@ViewBag.data" placeholder="e.g. India" popupHeight="220px">
            <e-autocomplete-fields value="Game" text="Id"></e-autocomplete-fields>
        </ejs-autocomplete>
    </div>
</div>
<script>
    document.onkeyup = function (e) {
        var atcObject = document.getElementById("default").ej2_instances[0];
        if (e.altKey && e.keyCode === 84 /* t */) {
            // press alt+t to focus the control.
            atcObject.focusIn();
        }
    };
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WebApplication1.Models
{
    public class GameList
    {
        public string Id { get; set; }
        public string Game { get; set; }

        public List<GameList> GameLists()
        {
            List<GameList> game = new List<GameList>();
            game.Add(new GameList { Id = "Game1", Game = "American Football" });
            game.Add(new GameList { Id = "Game2", Game = "Badminton" });
            game.Add(new GameList { Id = "Game3", Game = "Basketball" });
            game.Add(new GameList { Id = "Game3", Game = "Basketball" });
            game.Add(new GameList { Id = "Game4", Game = "Cricket" });
            game.Add(new GameList { Id = "Game5", Game = "Football" });
            game.Add(new GameList { Id = "Game6", Game = "Golf" });
            game.Add(new GameList { Id = "Game7", Game = "Hockey" });
            game.Add(new GameList { Id = "Game8", Game = "Rugby" });
            game.Add(new GameList { Id = "Game9", Game = "Snooker" });
            game.Add(new GameList { Id = "Game10", Game = "Tennis" });
            return game;
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebApplication1.Models;

namespace WebApplication1.Controllers
{
    public class AutoCompleteController : Controller
    {
        public IActionResult accessibility()
        {
            ViewBag.data = new GameList().GameLists();
            return View();
        }
    }
}