Keyboard Navigation

The keyboard navigation of the Dialog is always available.

When the Dialog is opened, the initial focus is set on the Dialog element. This approach enables the user to immediately select or navigate between the action buttons by using the Tab and Shift+Tab keys, and to close the Dialog with the Esc button.

You can set the initial focus to one of the action buttons by using the autoFocus attribute.

SHORTCUT DESCRIPTION
Esc Calls the onClose event handler.
Shift+Tab Moves the focus to the previous focusable element.
Tab Moves the focus to the next focusable element.

The following example is based on the official accessibility standard for a modal dialog.

import React from 'react';
import ReactDOM from 'react-dom';
import { Dialog, DialogActionsBar } from '@progress/kendo-react-dialogs';

class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            visible: true
        };
        this.handleClose = this.handleClose.bind(this);
    }

    handleClose = () => {
        this.setState({
            visible: false
        });
    }
    render() {
        return (
            <div>
                { this.state.visible && <Dialog height={300} width={450} onClose={this.handleClose}>
                    <p style={{ margin: "25px", textAlign: "center" }}>Add Delivery Address</p>
                    <div>
                        <div>
                            <label>
                                <span style={{ display: "inline-block", width: "50px", textAlign: "right", paddingRight: "0.5em" }}>Street:</span>
                                <input type="text" style={{ width: "27em", maxWidth: "70%" }} autoFocus={true}/>
                            </label>
                        </div>
                        <div>
                          <label>
                            <span style={{ display: "inline-block", width: "50px", textAlign: "right", paddingRight: "0.5em" }}>City:</span>
                            <input type="text" style={{ width: "27em", maxWidth: "70%" }}/>
                          </label>
                        </div>
                        <div>
                          <label>
                            <span style={{ display: "inline-block", width: "50px", textAlign: "right", paddingRight: "0.5em" }}>State:</span>
                            <input type="text" style={{ width: "27em", maxWidth: "70%" }}/>
                          </label>
                        </div>
                        <div>
                          <label>
                            <span style={{ display: "inline-block", width: "50px", textAlign: "right", paddingRight: "0.5em" }}>Zip:</span>
                            <input type="text" style={{ width: "27em", maxWidth: "70%" }}/>
                          </label>
                        </div>
                    </div>
                    <DialogActionsBar>
                        <button className="k-button">Verify Address</button>
                        <button className="k-button">Add</button>
                        <button className="k-button k-primary">Cancel</button>
                    </DialogActionsBar>
                </Dialog>}
            </div>
        );
    }
}
ReactDOM.render(
    <App />,
    document.querySelector('my-app')
);

In this article