Skip to content

Commit

Permalink
Fix being unable to switch modes while inserter is open (WordPress#61563
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jeryj authored and patil-vipul committed Jun 17, 2024
1 parent 47e2f89 commit 4d0902c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/block-editor/src/hooks/use-zoom-out.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export function useZoomOut( zoomOut = true ) {

return () => {
// We need to use __unstableGetEditorMode() here and not `mode`, as mode may not update on unmount
if ( __unstableGetEditorMode() !== originalEditingMode.current ) {
if (
__unstableGetEditorMode() === 'zoom-out' &&
__unstableGetEditorMode() !== originalEditingMode.current
) {
__unstableSetEditorMode( originalEditingMode.current );
}
};
Expand All @@ -39,7 +42,11 @@ export function useZoomOut( zoomOut = true ) {
useEffect( () => {
if ( zoomOut && mode !== 'zoom-out' ) {
__unstableSetEditorMode( 'zoom-out' );
} else if ( ! zoomOut && originalEditingMode.current !== mode ) {
} else if (
! zoomOut &&
__unstableGetEditorMode() === 'zoom-out' &&
originalEditingMode.current !== mode
) {
__unstableSetEditorMode( originalEditingMode.current );
}
}, [ __unstableSetEditorMode, zoomOut, mode ] );
Expand Down

0 comments on commit 4d0902c

Please sign in to comment.