Accessibility

4 Apr 20225 minutes to read

The Dialog characterized with complete ARIA Accessibility support helps to be accessible by on-screen readers and other assistive technology devices. This component is designed with the reference of the guidelines document given in WAI ARAI Accessibility Practices.

The Dialog control uses the Dialog role and following ARIA properties to its element based on its state.

Property Functionalities
aria-describedby It indicates the Dialog content description that is notified to the user through assistive technologies.
aria-labelledby The Dialog title is notified to the user through assistive technologies.
aria-modal For modal dialog its value is true and for non-modal dialog its value is false.
aria-grabbed Enables the draggable Dialog and starts dragging its value is true and stopping the drag its value is false.

Keyboard interaction

Keyboard interaction of Dialog control has been designed based on WAI-ARIA Practices described for Dialog. User can use the following shortcut keys to interact with the Dialog.

Keyboard shortcuts Actions
Esc Closes the Dialog. This functionality can be controlled by using `closeOnEscape`
Enter When the Dialog button or any input (except text area) is in focus state, when pressing the Enter key, the click event associated with the primary button or button will trigger. Enter key is not working when the Dialog content contains any text area with initial focus.
Ctrl + Enter When the Dialog content contains text area and it is in focus state, and press the Ctrl + Enter key to call the click event function associated with primary button.
Tab Focus will be changed within the Dialog elements
Shift + Tab The Focus will be changed previous focusable element within the Dialog elements. When focusing a first focusable element in the Dialog, then press the shift + tab key, it will change the focus to last focusable element.
<div id='container' style="height:400px;">
        <ejs-button id="targetButton" content="Open Dialog"></ejs-button>
        <ejs-dialog id="dialog" header="Feedback" showCloseIcon="true" target="#container" width="400px" height="300px">
            <e-content-template>
                <form>
                    <div class='form-group'>
                        <label for='email'>Email:</label><input type='email' class='form-control' id='email'>
                    </div><div class='form-group'>
                    </div><div class='form-group'>
                        <label for='comment'>Comments:</label><textarea style='resize: none;' class='form-control' rows='5' id='comment'></textarea>
                    </div>
                </form>
            </e-content-template>
            <e-dialog-buttons>
                <e-dialog-dialogbutton buttonModel="@ViewBag.DialogButtons" click="dlgButtonClick"></e-dialog-dialogbutton>
            </e-dialog-buttons>
        </ejs-dialog>
    </div>
<script>
    window.onload = function () {
        document.getElementById('targetButton').onclick = function () {
            var dialog = document.getElementById("dialog").ej2_instances[0];
            dialog.show();
        }
    }
    function dlgButtonClick() {
        var dialogObj = document.getElementById('dialog').ej2_instances[0];
        dialogObj.hide();
    }
</script>
public class HomeController : Controller
{
    public class ButtonModel
    {
        public string content { get; set; }
        public string cssClass { get; set; }
    }

    public ActionResult Index()
    {
        ViewBag.DialogButtons = new ButtonModel() { cssClass = "e-flat", content = "Submit" };
        return View();
    }
}

See Also