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

Accessibility improvement on #29530 issue #29534

Merged
merged 11 commits into from
Mar 10, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { useState, useEffect, useRef } from '@wordpress/element';
import { ESCAPE } from '@wordpress/keycodes';

/**
* Internal dependencies
*/
import ContentNavigation from './content-navigation';
import TemplatesNavigation from './templates-navigation';
import { useSelect } from '@wordpress/data';
import { useSelect, useDispatch } from '@wordpress/data';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you didn't add this here, and wont block the PR on it. But just noticing this import should fall under the "WordPress dependencies" group of imports above.

Copy link
Contributor Author

@Quintis1212 Quintis1212 Mar 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Addison-Stavlo thank you for help !) I updated the dependencies group )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

import { MENU_ROOT } from './constants';
import { store as editSiteStore } from '../../../store';

Expand Down Expand Up @@ -41,13 +42,23 @@ const NavigationPanel = ( { isOpen } ) => {
}
}, [ templatesActiveMenu ] );

const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );

const closeOnEscape = ( event ) => {
if ( event.keyCode === ESCAPE ) {
event.stopPropagation();
setIsNavigationPanelOpened( false );
}
};

return (
<div
className={ classnames( `edit-site-navigation-panel`, {
'is-open': isOpen,
} ) }
ref={ panelRef }
tabIndex="-1"
onKeyDown={ closeOnEscape }
>
<div className="edit-site-navigation-panel__inner">
<div className="edit-site-navigation-panel__site-title-container">
Expand Down