Skip to content

Commit

Permalink
In mobile mode, check for canvas edit mode so the "Edit" callback red…
Browse files Browse the repository at this point in the history
…irect the browser to the block editor in edit mode
  • Loading branch information
ramonjd committed Jul 1, 2024
1 parent fced091 commit 9d7f618
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions packages/edit-site/src/components/layout/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export default function useLayoutAreas() {
const isSiteEditorLoading = useIsSiteEditorLoading();
const { params } = useLocation();
const { postType, postId, path, layout, isCustom, canvas } = params;
const hasEditCanvasMode = canvas === 'edit';
useRedirectOldPaths();

// Page list
Expand All @@ -93,7 +94,7 @@ export default function useLayoutAreas() {
/>
),
content: <PagePages />,
preview: ( isListLayout || canvas === 'edit' ) && (
preview: ( isListLayout || hasEditCanvasMode ) && (
<Editor isLoading={ isSiteEditorLoading } />
),
mobile:
Expand All @@ -119,10 +120,14 @@ export default function useLayoutAreas() {
<SidebarNavigationScreenTemplatesBrowse backPath={ {} } />
),
content: <PageTemplates />,
preview: ( isListLayout || canvas === 'edit' ) && (
preview: ( isListLayout || hasEditCanvasMode ) && (
<Editor isLoading={ isSiteEditorLoading } />
),
mobile: <PageTemplates />,
mobile: hasEditCanvasMode ? (
<Editor isLoading={ isSiteEditorLoading } />
) : (
<PageTemplates />
),
},
widths: {
content: isListLayout ? 380 : undefined,
Expand All @@ -139,8 +144,12 @@ export default function useLayoutAreas() {
areas: {
sidebar: <SidebarNavigationScreenPatterns backPath={ {} } />,
content: <PagePatterns />,
mobile: <PagePatterns />,
preview: canvas === 'edit' && (
mobile: hasEditCanvasMode ? (
<Editor isLoading={ isSiteEditorLoading } />
) : (
<PagePatterns />
),
preview: hasEditCanvasMode && (
<Editor isLoading={ isSiteEditorLoading } />
),
},
Expand All @@ -156,7 +165,7 @@ export default function useLayoutAreas() {
<SidebarNavigationScreenGlobalStyles backPath={ {} } />
),
preview: <Editor isLoading={ isSiteEditorLoading } />,
mobile: canvas === 'edit' && (
mobile: hasEditCanvasMode && (
<Editor isLoading={ isSiteEditorLoading } />
),
},
Expand All @@ -175,7 +184,7 @@ export default function useLayoutAreas() {
/>
),
preview: <Editor isLoading={ isSiteEditorLoading } />,
mobile: canvas === 'edit' && (
mobile: hasEditCanvasMode && (
<Editor isLoading={ isSiteEditorLoading } />
),
},
Expand All @@ -188,7 +197,7 @@ export default function useLayoutAreas() {
<SidebarNavigationScreenNavigationMenus backPath={ {} } />
),
preview: <Editor isLoading={ isSiteEditorLoading } />,
mobile: canvas === 'edit' && (
mobile: hasEditCanvasMode && (
<Editor isLoading={ isSiteEditorLoading } />
),
},
Expand All @@ -201,7 +210,7 @@ export default function useLayoutAreas() {
areas: {
sidebar: <SidebarNavigationScreenMain />,
preview: <Editor isLoading={ isSiteEditorLoading } />,
mobile: canvas === 'edit' && (
mobile: hasEditCanvasMode && (
<Editor isLoading={ isSiteEditorLoading } />
),
},
Expand Down

0 comments on commit 9d7f618

Please sign in to comment.