Skip to content

Commit c926d69

Browse files
PARTHVATALIYAPARTHVATALIYAt-hamanogetdave
authored
Fix: Activate zoom out on large viewport (#66308)
* Activate zoom out on large viewport * Reset zoom out when view-port change to medium --------- Co-authored-by: PARTHVATALIYA <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: getdave <[email protected]>
1 parent ca8c191 commit c926d69

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/block-editor/src/hooks/use-zoom-out.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useEffect } from '@wordpress/element';
99
*/
1010
import { store as blockEditorStore } from '../store';
1111
import { unlock } from '../lock-unlock';
12+
import { useViewportMatch } from '@wordpress/compose';
1213

1314
/**
1415
* A hook used to set the editor mode to zoomed out mode, invoking the hook sets the mode.
@@ -20,12 +21,13 @@ export function useZoomOut( zoomOut = true ) {
2021
useDispatch( blockEditorStore )
2122
);
2223
const { isZoomOut } = unlock( useSelect( blockEditorStore ) );
24+
const isWideViewport = useViewportMatch( 'large' );
2325

2426
useEffect( () => {
2527
const isZoomOutOnMount = isZoomOut();
2628

2729
return () => {
28-
if ( isZoomOutOnMount ) {
30+
if ( isZoomOutOnMount && isWideViewport ) {
2931
setZoomLevel( 50 );
3032
} else {
3133
resetZoomLevel();
@@ -34,10 +36,10 @@ export function useZoomOut( zoomOut = true ) {
3436
}, [] );
3537

3638
useEffect( () => {
37-
if ( zoomOut ) {
39+
if ( zoomOut && isWideViewport ) {
3840
setZoomLevel( 50 );
3941
} else {
4042
resetZoomLevel();
4143
}
42-
}, [ zoomOut, setZoomLevel, resetZoomLevel ] );
44+
}, [ zoomOut, setZoomLevel, resetZoomLevel, isWideViewport ] );
4345
}

0 commit comments

Comments
 (0)