From 80919d079d76b48b71f5301651b9ed51f1c358c9 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Fri, 25 Oct 2024 11:15:24 +0100 Subject: [PATCH] Don't switch editor mode when changing entities (#66452) * Only reset zoom level * Avoid set editor mode on sidebar toggle Co-authored-by: getdave Co-authored-by: youknowriad Co-authored-by: Ella <4710635+ellatrix@users.noreply.github.com> --- packages/edit-site/src/components/editor/index.js | 7 +------ .../use-init-edited-entity-from-url.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/edit-site/src/components/editor/index.js b/packages/edit-site/src/components/editor/index.js index 9058a163707997..c7481a1d12bd79 100644 --- a/packages/edit-site/src/components/editor/index.js +++ b/packages/edit-site/src/components/editor/index.js @@ -153,9 +153,7 @@ export default function EditSiteEditor( { isPostsList = false } ) { ], [ settings.styles, canvas, currentPostIsTrashed ] ); - const { __unstableSetEditorMode, resetZoomLevel } = unlock( - useDispatch( blockEditorStore ) - ); + const { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) ); const { createSuccessNotice } = useDispatch( noticesStore ); const history = useHistory(); const onActionPerformed = useCallback( @@ -263,9 +261,6 @@ export default function EditSiteEditor( { isPostsList = false } ) { showTooltip tooltipPosition="middle right" onClick={ () => { - __unstableSetEditorMode( - 'edit' - ); resetZoomLevel(); // TODO: this is a temporary solution to navigate to the posts list if we are diff --git a/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js b/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js index 9f507693c4cfdc..35eeb5963fb546 100644 --- a/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +++ b/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js @@ -249,15 +249,19 @@ export default function useInitEditedEntityFromURL() { useResolveEditedEntityAndContext( params ); const { setEditedEntity } = useDispatch( editSiteStore ); - const { __unstableSetEditorMode, resetZoomLevel } = unlock( - useDispatch( blockEditorStore ) - ); + const { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) ); useEffect( () => { if ( isReady ) { - __unstableSetEditorMode( 'edit' ); resetZoomLevel(); setEditedEntity( postType, postId, context ); } - }, [ isReady, postType, postId, context, setEditedEntity ] ); + }, [ + isReady, + postType, + postId, + context, + setEditedEntity, + resetZoomLevel, + ] ); }