Skip to content

Commit

Permalink
Only render resize handle when in View mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Jul 12, 2023
1 parent f5bbecd commit 5acbbfd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/edit-site/src/components/resizable-frame/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
__unstableMotion as motion,
} from '@wordpress/components';
import { useInstanceId } from '@wordpress/compose';
import { useDispatch } from '@wordpress/data';
import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';

/**
Expand Down Expand Up @@ -90,6 +90,10 @@ function ResizableFrame( {
const [ shouldShowHandle, setShouldShowHandle ] = useState( false );
const [ isOversized, setIsOversized ] = useState( false );
const [ resizeRatio, setResizeRatio ] = useState( 1 );
const canvasMode = useSelect(
( select ) => unlock( select( editSiteStore ) ).getCanvasMode(),
[]
);
const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
const initialAspectRatioRef = useRef( null );
// The width of the resizable frame on initial render.
Expand Down Expand Up @@ -265,7 +269,7 @@ function ResizableFrame( {
onMouseOver={ () => setShouldShowHandle( true ) }
onMouseOut={ () => setShouldShowHandle( false ) }
handleComponent={ {
left: (
left: canvasMode === 'view' && (
<>
<Tooltip text={ __( 'Drag to resize' ) }>
{ /* Disable reason: role="separator" does in fact support aria-valuenow */ }
Expand Down

0 comments on commit 5acbbfd

Please sign in to comment.