Skip to content

Commit

Permalink
Don't switch editor mode when changing entities (WordPress#66452)
Browse files Browse the repository at this point in the history
* Only reset zoom level

* Avoid set editor mode on sidebar toggle

Co-authored-by: getdave <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: Ella <[email protected]>
  • Loading branch information
4 people authored and karthick-murugan committed Nov 13, 2024
1 parent 9a876cd commit 80919d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
7 changes: 1 addition & 6 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
] );
}

0 comments on commit 80919d0

Please sign in to comment.