Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing in Auto mode shouldn't add columnStart and rowStart values #63160

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading