Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Dashboard: Fix focusTrap import #17935

Merged
merged 1 commit into from
Dec 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions _inc/client/components/modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import { assign, omit } from 'lodash';
import focusTrap from 'focus-trap';
import { createFocusTrap } from 'focus-trap';

// this flag will prevent ANY modals from closing.
// use with caution!
Expand Down Expand Up @@ -51,7 +51,8 @@ class Modal extends React.Component {
jQuery( 'body' ).addClass( 'dops-modal-showing' ).on( 'touchmove.dopsmodal', false );
jQuery( document ).keyup( this.handleEscapeKey );
try {
focusTrap.activate( ReactDOM.findDOMNode( this ), {
this.focusTrap = createFocusTrap( ReactDOM.findDOMNode( this ) );
this.focusTrap.activate( {
// onDeactivate: this.maybeClose,
initialFocus: this.props.initialFocus,
} );
Expand All @@ -64,7 +65,7 @@ class Modal extends React.Component {
jQuery( 'body' ).removeClass( 'dops-modal-showing' ).off( 'touchmove.dopsmodal', false );
jQuery( document ).unbind( 'keyup', this.handleEscapeKey );
try {
focusTrap.deactivate();
this.focusTrap.deactivate();
} catch ( e ) {
//noop
}
Expand Down