Skip to content

Commit

Permalink
Highlight "Site" in the navigation panel (#36762)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed Nov 24, 2021
1 parent b0b3f3f commit 87460a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Expand Up @@ -46,7 +46,7 @@ export default function NavigationSidebar( {
<NavigationPanel
isOpen={ isNavigationOpen }
setIsOpen={ setIsNavigationOpen }
activeTemplateType={ activeTemplateType }
activeItem={ activeTemplateType }
/>
<NavigationPanelPreviewSlot />
</>
Expand Down
Expand Up @@ -26,7 +26,13 @@ import { addQueryArgs } from '@wordpress/url';
*/
import MainDashboardButton from '../../main-dashboard-button';

const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
const SITE_EDITOR_KEY = 'site-editor';

const NavigationPanel = ( {
isOpen,
setIsOpen,
activeItem = SITE_EDITOR_KEY,
} ) => {
const siteTitle = useSelect( ( select ) => {
const { getEntityRecord } = select( coreDataStore );

Expand All @@ -43,7 +49,7 @@ const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
if ( isOpen ) {
panelRef.current.focus();
}
}, [ activeTemplateType, isOpen ] );
}, [ activeItem, isOpen ] );

const closeOnEscape = ( event ) => {
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
Expand All @@ -69,7 +75,7 @@ const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
</div>
</div>
<div className="edit-site-navigation-panel__scroll-container">
<Navigation activeItem={ activeTemplateType }>
<Navigation activeItem={ activeItem }>
<MainDashboardButton.Slot>
<NavigationBackButton
backButtonLabel={ __( 'Dashboard' ) }
Expand All @@ -82,6 +88,7 @@ const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
<NavigationGroup title={ __( 'Editor' ) }>
<NavigationItem
title={ __( 'Site' ) }
item={ SITE_EDITOR_KEY }
href={ addQueryArgs( window.location.href, {
postId: undefined,
postType: undefined,
Expand Down

0 comments on commit 87460a4

Please sign in to comment.