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

Site Hub: Navigate correctly in mobile view #69157

Merged
merged 1 commit into from
Feb 13, 2025
Merged
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
38 changes: 17 additions & 21 deletions packages/edit-site/src/components/site-hub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
import { store as editSiteStore } from '../../store';
import SiteIcon from '../site-icon';
import { unlock } from '../../lock-unlock';
const { useHistory } = unlock( routerPrivateApis );
import { SidebarNavigationContext } from '../sidebar';
const { useLocation, useHistory } = unlock( routerPrivateApis );

const SiteHub = memo(
forwardRef( ( { isTransparent }, ref ) => {
Expand Down Expand Up @@ -117,29 +117,25 @@ export default SiteHub;

export const SiteHubMobile = memo(
forwardRef( ( { isTransparent }, ref ) => {
const { path } = useLocation();
const history = useHistory();
const { navigate } = useContext( SidebarNavigationContext );

const { dashboardLink, isBlockTheme, homeUrl, siteTitle } = useSelect(
( select ) => {
const { getSettings } = unlock( select( editSiteStore ) );

const { getEntityRecord, getCurrentTheme } =
select( coreStore );
const _site = getEntityRecord( 'root', 'site' );
return {
dashboardLink: getSettings().__experimentalDashboardLink,
isBlockTheme: getCurrentTheme()?.is_block_theme,
homeUrl: getEntityRecord( 'root', '__unstableBase' )?.home,
siteTitle:
! _site?.title && !! _site?.url
? filterURLForDisplay( _site?.url )
: _site?.title,
};
},
[]
);
const { dashboardLink, homeUrl, siteTitle } = useSelect( ( select ) => {
const { getSettings } = unlock( select( editSiteStore ) );
const { getEntityRecord } = select( coreStore );
const _site = getEntityRecord( 'root', 'site' );
return {
dashboardLink: getSettings().__experimentalDashboardLink,
homeUrl: getEntityRecord( 'root', '__unstableBase' )?.home,
siteTitle:
! _site?.title && !! _site?.url
? filterURLForDisplay( _site?.url )
: _site?.title,
};
}, [] );
const { open: openCommandCenter } = useDispatch( commandsStore );
const isRoot = path === '/';

return (
<div className="edit-site-site-hub">
Expand All @@ -160,7 +156,7 @@ export const SiteHubMobile = memo(
transform: 'scale(0.5)',
borderRadius: 4,
} }
{ ...( ! isBlockTheme
{ ...( isRoot
? {
href: dashboardLink,
label: __( 'Go to the Dashboard' ),
Expand Down
Loading