Skip to content

Commit

Permalink
Resizing in Auto mode shouldn't add columnStart and rowStart valu…
Browse files Browse the repository at this point in the history
…es (WordPress#63160)

Co-authored-by: tellthemachines <[email protected]>
Co-authored-by: noisysocks <[email protected]>
  • Loading branch information
3 people authored Jul 5, 2024
1 parent aaadab3 commit ccc5b43
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/block-mover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function BlockMover( {
orientation: getBlockListSettings( _rootClientId )?.orientation,
isManualGrid:
layout.type === 'grid' &&
!! layout.columnCount &&
layout.isManualPlacement &&
window.__experimentalEnableGridInteractivity,
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function GridItemResizer( {
} ) {
const blockElement = useBlockElement( clientId );
const rootBlockElement = blockElement?.parentElement;
const { columnCount } = parentLayout;
const { isManualPlacement } = parentLayout;

if ( ! blockElement || ! rootBlockElement ) {
return null;
Expand All @@ -33,7 +33,8 @@ export function GridItemResizer( {
rootBlockElement={ rootBlockElement }
onChange={ onChange }
isManualGrid={
!! columnCount && window.__experimentalEnableGridInteractivity
isManualPlacement &&
window.__experimentalEnableGridInteractivity
}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function GridVisualizer( { clientId, contentRef, parentLayout } ) {
}

const isManualGrid =
parentLayout?.columnCount &&
parentLayout?.isManualPlacement &&
window.__experimentalEnableGridInteractivity;
return (
<GridVisualizerGrid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
const updates = {};

const { columnCount, rowCount, isManualPlacement } = gridLayout;
const isManualGrid = !! isManualPlacement;

if ( isManualGrid ) {
if ( isManualPlacement ) {
const rects = [];

// Respect the position of blocks that already have a columnStart and rowStart value.
Expand Down
23 changes: 11 additions & 12 deletions packages/block-editor/src/hooks/layout-child.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function ChildLayoutControlsPure( { clientId, style, setAttributes } ) {
const {
type: parentLayoutType = 'default',
allowSizingOnChildren = false,
columnCount,
isManualPlacement,
} = parentLayout;

const rootClientId = useSelect(
Expand All @@ -169,8 +169,6 @@ function ChildLayoutControlsPure( { clientId, style, setAttributes } ) {
return null;
}

const isManualGrid = !! columnCount;

function updateLayout( layout ) {
setAttributes( {
style: {
Expand Down Expand Up @@ -199,15 +197,16 @@ function ChildLayoutControlsPure( { clientId, style, setAttributes } ) {
parentLayout={ parentLayout }
/>
) }
{ isManualGrid && window.__experimentalEnableGridInteractivity && (
<GridItemMovers
layout={ style?.layout }
parentLayout={ parentLayout }
onChange={ updateLayout }
gridClientId={ rootClientId }
blockClientId={ clientId }
/>
) }
{ isManualPlacement &&
window.__experimentalEnableGridInteractivity && (
<GridItemMovers
layout={ style?.layout }
parentLayout={ parentLayout }
onChange={ updateLayout }
gridClientId={ rootClientId }
blockClientId={ clientId }
/>
) }
</>
);
}
Expand Down

0 comments on commit ccc5b43

Please sign in to comment.