diff --git a/packages/edit-site/src/components/layout/router.js b/packages/edit-site/src/components/layout/router.js
index 36ca52088f6a8..4637b9e1f6110 100644
--- a/packages/edit-site/src/components/layout/router.js
+++ b/packages/edit-site/src/components/layout/router.js
@@ -75,6 +75,7 @@ function useRedirectOldPaths() {
export default function useLayoutAreas() {
const { params } = useLocation();
const { postType, postId, path, layout, isCustom, canvas } = params;
+ const hasEditCanvasMode = canvas === 'edit';
useRedirectOldPaths();
// Page list
@@ -91,13 +92,12 @@ export default function useLayoutAreas() {
/>
),
content: ,
- preview: ( isListLayout || canvas === 'edit' ) && ,
- mobile:
- canvas === 'edit' ? (
-
- ) : (
-
- ),
+ preview: ( isListLayout || hasEditCanvasMode ) && ,
+ mobile: hasEditCanvasMode ? (
+
+ ) : (
+
+ ),
},
widths: {
content: isListLayout ? 380 : undefined,
@@ -115,8 +115,8 @@ export default function useLayoutAreas() {
),
content: ,
- preview: ( isListLayout || canvas === 'edit' ) && ,
- mobile: ,
+ preview: ( isListLayout || hasEditCanvasMode ) && ,
+ mobile: hasEditCanvasMode ? : ,
},
widths: {
content: isListLayout ? 380 : undefined,
@@ -133,8 +133,8 @@ export default function useLayoutAreas() {
areas: {
sidebar: ,
content: ,
- mobile: ,
- preview: canvas === 'edit' && ,
+ mobile: hasEditCanvasMode ? : ,
+ preview: hasEditCanvasMode && ,
},
};
}
@@ -148,7 +148,7 @@ export default function useLayoutAreas() {
),
preview: ,
- mobile: canvas === 'edit' && ,
+ mobile: hasEditCanvasMode && ,
},
};
}
@@ -165,7 +165,7 @@ export default function useLayoutAreas() {
/>
),
preview: ,
- mobile: canvas === 'edit' && ,
+ mobile: hasEditCanvasMode && ,
},
};
}
@@ -176,7 +176,7 @@ export default function useLayoutAreas() {
),
preview: ,
- mobile: canvas === 'edit' && ,
+ mobile: hasEditCanvasMode && ,
},
};
}
@@ -187,7 +187,7 @@ export default function useLayoutAreas() {
areas: {
sidebar: ,
preview: ,
- mobile: canvas === 'edit' && ,
+ mobile: hasEditCanvasMode && ,
},
};
}
diff --git a/packages/edit-site/src/store/private-actions.js b/packages/edit-site/src/store/private-actions.js
index bd56e30f10d11..37164690ed7fc 100644
--- a/packages/edit-site/src/store/private-actions.js
+++ b/packages/edit-site/src/store/private-actions.js
@@ -13,10 +13,10 @@ import { store as editorStore } from '@wordpress/editor';
export const setCanvasMode =
( mode ) =>
( { registry, dispatch } ) => {
+ const isMediumOrBigger =
+ window.matchMedia( '(min-width: 782px)' ).matches;
const switchCanvasMode = () => {
registry.batch( () => {
- const isMediumOrBigger =
- window.matchMedia( '(min-width: 782px)' ).matches;
registry.dispatch( blockEditorStore ).clearSelectedBlock();
registry.dispatch( editorStore ).setDeviceType( 'Desktop' );
registry
@@ -59,7 +59,11 @@ export const setCanvasMode =
} );
};
- if ( ! document.startViewTransition ) {
+ /*
+ * Skip transition in mobile, otherwise it crashes the browser.
+ * See: https://github.com/WordPress/gutenberg/pull/63002.
+ */
+ if ( ! isMediumOrBigger || ! document.startViewTransition ) {
switchCanvasMode();
} else {
document.documentElement.classList.add(