Skip to content

Commit

Permalink
Only show grid resizer if grid block allows resizing on children. (#6…
Browse files Browse the repository at this point in the history
…1552)

Co-authored-by: tellthemachines <[email protected]>
Co-authored-by: andrewserong <[email protected]>
  • Loading branch information
3 people authored May 10, 2024
1 parent df77d44 commit 4d1c083
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions packages/block-editor/src/hooks/layout-child.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,17 @@ function useBlockPropsChildLayoutStyles( { style } ) {

function ChildLayoutControlsPure( { clientId, style, setAttributes } ) {
const parentLayout = useLayout() || {};
const {
type: parentLayoutType = 'default',
allowSizingOnChildren = false,
} = parentLayout;
const rootClientId = useSelect(
( select ) => {
return select( blockEditorStore ).getBlockRootClientId( clientId );
},
[ clientId ]
);
if ( parentLayout.type !== 'grid' ) {
if ( parentLayoutType !== 'grid' ) {
return null;
}
if ( ! window.__experimentalEnableGridInteractivity ) {
Expand All @@ -150,21 +154,23 @@ function ChildLayoutControlsPure( { clientId, style, setAttributes } ) {
return (
<>
<GridVisualizer clientId={ rootClientId } />
<GridItemResizer
clientId={ clientId }
onChange={ ( { columnSpan, rowSpan } ) => {
setAttributes( {
style: {
...style,
layout: {
...style?.layout,
columnSpan,
rowSpan,
{ allowSizingOnChildren && (
<GridItemResizer
clientId={ clientId }
onChange={ ( { columnSpan, rowSpan } ) => {
setAttributes( {
style: {
...style,
layout: {
...style?.layout,
columnSpan,
rowSpan,
},
},
},
} );
} }
/>
} );
} }
/>
) }
</>
);
}
Expand Down

0 comments on commit 4d1c083

Please sign in to comment.