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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extra tab stop on Modal component #22063

Merged
merged 3 commits into from
May 8, 2020
Merged
Show file tree
Hide file tree
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
14 changes: 1 addition & 13 deletions packages/components/src/modal/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import classnames from 'classnames';

import { Component, createRef } from '@wordpress/element';
import { ESCAPE } from '@wordpress/keycodes';
import { focus } from '@wordpress/dom';
import { compose } from '@wordpress/compose';

/**
Expand All @@ -27,7 +26,6 @@ class ModalFrame extends Component {
this.containerRef = createRef();
this.handleKeyDown = this.handleKeyDown.bind( this );
this.handleFocusOutside = this.handleFocusOutside.bind( this );
this.focusFirstTabbable = this.focusFirstTabbable.bind( this );
}

/**
Expand All @@ -36,17 +34,7 @@ class ModalFrame extends Component {
componentDidMount() {
// Focus on mount
if ( this.props.focusOnMount ) {
this.focusFirstTabbable();
}
}

/**
* Focuses the first tabbable element.
*/
focusFirstTabbable() {
const tabbables = focus.tabbable.find( this.containerRef.current );
if ( tabbables.length ) {
tabbables[ 0 ].focus();
this.containerRef.current.focus();
}
}

Expand Down
6 changes: 1 addition & 5 deletions packages/components/src/modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,7 @@ class Modal extends Component {
} }
{ ...otherProps }
>
<div
className={ 'components-modal__content' }
tabIndex="0"
role="document"
>
<div className={ 'components-modal__content' } role="document">
<ModalHeader
closeLabel={ closeButtonLabel }
headingId={ headingId }
Expand Down