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 (#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 <yogeshbhutkar@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: ironprogrammer <ironprogrammer@git.wordpress.org>
  • 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

1 comment on commit aba08da

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in aba08da.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11817284433
📝 Reported issues:

Please sign in to comment.