Skip to content

Commit

Permalink
Site Hub: Fixed navigation redirect on mobile devices for classic the…
Browse files Browse the repository at this point in the history
…mes (WordPress#66867)

* Site Hub: Enhance mobile component with dashboard link and block theme detection

* Site Hub: Simplify dashboard link rendering logic for non-block themes

* Site Hub: Remove fallback for block theme detection in mobile component

Co-authored-by: yogeshbhutkar <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: ironprogrammer <[email protected]>
  • Loading branch information
4 people authored Nov 13, 2024
1 parent 201f6a7 commit aba08da
Showing 1 changed file with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions packages/edit-site/src/components/site-hub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,27 @@ export const SiteHubMobile = memo(
const history = useHistory();
const { navigate } = useContext( SidebarNavigationContext );

const { homeUrl, siteTitle } = useSelect( ( select ) => {
const { getEntityRecord } = select( coreStore );
const _site = getEntityRecord( 'root', 'site' );
return {
homeUrl: getEntityRecord( 'root', '__unstableBase' )?.home,
siteTitle:
! _site?.title && !! _site?.url
? filterURLForDisplay( _site?.url )
: _site?.title,
};
}, [] );
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 ||
'index.php',
isBlockTheme: getCurrentTheme()?.is_block_theme,
homeUrl: getEntityRecord( 'root', '__unstableBase' )?.home,
siteTitle:
! _site?.title && !! _site?.url
? filterURLForDisplay( _site?.url )
: _site?.title,
};
},
[]
);
const { open: openCommandCenter } = useDispatch( commandsStore );

return (
Expand All @@ -148,16 +158,23 @@ export const SiteHubMobile = memo(
<Button
__next40pxDefaultSize
ref={ ref }
label={ __( 'Go to Site Editor' ) }
className="edit-site-layout__view-mode-toggle"
style={ {
transform: 'scale(0.5)',
borderRadius: 4,
} }
onClick={ () => {
history.push( {} );
navigate( 'back' );
} }
{ ...( ! isBlockTheme
? {
href: dashboardLink,
label: __( 'Go to the Dashboard' ),
}
: {
onClick: () => {
history.push( {} );
navigate( 'back' );
},
label: __( 'Go to Site Editor' ),
} ) }
>
<SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
</Button>
Expand Down

0 comments on commit aba08da

Please sign in to comment.