How to use the focus-trap.activate function in focus-trap

To help you get started, we’ve selected a few focus-trap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Automattic / jetpack / _inc / client / components / modal / index.jsx View on Github external
componentDidMount() {
		jQuery( 'body' )
			.addClass( 'dops-modal-showing' )
			.on( 'touchmove.dopsmodal', false );
		jQuery( document ).keyup( this.handleEscapeKey );
		try {
			focusTrap.activate( ReactDOM.findDOMNode( this ), {
				// onDeactivate: this.maybeClose,
				initialFocus: this.props.initialFocus,
			} );
		} catch ( e ) {
			//noop
		}
	}
github springload / frontend-starter-kit / core / static_src / js / components / modals / Modal.js View on Github external
setFocusTrap() {
        const { modal, content } = this.refs;
        const tabbableItems = tabbable(content);
        if (tabbableItems.length > 0) {
            focusTrap.activate(modal);
        }
    },

focus-trap

Trap focus within a DOM node.

MIT
Latest version published 7 months ago

Package Health Score

90 / 100
Full package analysis