Skip to content

Commit

Permalink
Don't switch editor mode when changing entities (#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 <get_dave@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: Ella <4710635+ellatrix@users.noreply.github.com>
  • Loading branch information
4 people authored Oct 25, 2024
1 parent 56e011b commit 7cda674
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,
] );
}

1 comment on commit 7cda674

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 7cda674.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11516313165
📝 Reported issues:

Please sign in to comment.