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: Fixed navigation redirect on mobile devices for classic themes #66867

Merged
merged 3 commits into from
Nov 13, 2024
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
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
Loading