Skip to content

Commit

Permalink
Fix row situation when converting from auto to manual
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Jun 17, 2024
1 parent 73b821a commit 9dff09b
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
useEffect( () => {
const updates = {};

const { columnCount, rowCount } = gridLayout;
const { columnCount, rowCount = 2 } = gridLayout;

const isManualGrid = !! columnCount;

if ( isManualGrid ) {
const rects = [];

const minimumNeededRows = Math.max(
Math.ceil( blockOrder.length / columnCount ),
rowCount
);
// Respect the position of blocks that already have a columnStart and rowStart value.
for ( const clientId of blockOrder ) {
const attributes = getBlockAttributes( clientId );
Expand Down Expand Up @@ -65,7 +69,7 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
const [ newColumnStart, newRowStart ] = getFirstEmptyCell(
rects,
columnCount,
rowCount,
minimumNeededRows,
columnSpan,
rowSpan
);
Expand Down

0 comments on commit 9dff09b

Please sign in to comment.