Skip to content

Commit

Permalink
Site Editor: Only mark the 'Site' menu item active when editing a hom…
Browse files Browse the repository at this point in the history
…e template
  • Loading branch information
Mamaduka committed Jul 29, 2022
1 parent f945a8c commit 4fff454
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions packages/edit-site/src/components/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import List from '../list';
import NavigationSidebar from '../navigation-sidebar';
import getIsListPage from '../../utils/get-is-list-page';

export default function EditSiteApp( { reboot } ) {
export default function EditSiteApp( { reboot, homeTemplate } ) {
const { createErrorNotice } = useDispatch( noticesStore );

function onPluginAreaError( name ) {
Expand All @@ -39,6 +39,10 @@ export default function EditSiteApp( { reboot } ) {
<Routes>
{ ( { params } ) => {
const isListPage = getIsListPage( params );
const homeTemplateType =
params.postId === homeTemplate?.postId
? 'site-editor'
: undefined;

return (
<>
Expand All @@ -54,7 +58,9 @@ export default function EditSiteApp( { reboot } ) {
// Open the navigation sidebar by default when in the list page.
isDefaultOpen={ !! isListPage }
activeTemplateType={
isListPage ? params.postType : undefined
isListPage
? params.postType
: homeTemplateType
}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function NavLink( { params, replace, ...props } ) {
return <NavigationItem { ...linkProps } { ...props } />;
}

const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
const NavigationPanel = ( { activeItem } ) => {
const { homeTemplate, isNavigationOpen, siteTitle } = useSelect(
( select ) => {
const { getEntityRecord } = select( coreDataStore );
Expand Down
8 changes: 7 additions & 1 deletion packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ export function reinitializeEditor( target, settings ) {
}
}

render( <EditSiteApp reboot={ reboot } />, target );
render(
<EditSiteApp
reboot={ reboot }
homeTemplate={ settings.__unstableHomeTemplate }
/>,
target
);
}

/**
Expand Down

0 comments on commit 4fff454

Please sign in to comment.