Skip to content

Commit

Permalink
React Dashboard: Fix focusTrap import (#17935)
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham authored Dec 1, 2020
1 parent 2f3d6a7 commit a4175da
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit a4175da

Please sign in to comment.