Skip to content

Commit fe8cc84

Browse files
defaults for non-existing values
1 parent 34787ef commit fe8cc84

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

packages/block-editor/src/components/grid/use-grid-layout-sync.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,26 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
5757
);
5858
bottomMostRow = Math.max(
5959
bottomMostRow,
60-
rowStart + rowSpan - 1
60+
parseInt( rowStart, 10 ) + parseInt( rowSpan, 10 ) - 1
6161
);
6262
}
6363

6464
// When in manual mode, ensure that every block has a columnStart and rowStart value.
6565
for ( const clientId of blockOrder ) {
6666
const attributes = getBlockAttributes( clientId );
67-
const { columnStart, rowStart, columnSpan, rowSpan } =
68-
attributes.style?.layout || {};
67+
const {
68+
columnStart,
69+
rowStart,
70+
columnSpan = 1,
71+
rowSpan = 1,
72+
} = attributes.style?.layout || {};
6973
if ( columnStart && rowStart ) {
7074
continue;
7175
}
7276
const [ newColumnStart, newRowStart ] = getFirstEmptyCell(
7377
rects,
7478
columnCount,
75-
Math.max( rowCount, bottomMostRow ),
79+
Math.max( rowCount || 2, bottomMostRow ),
7680
columnSpan,
7781
rowSpan
7882
);
@@ -96,7 +100,7 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
96100
};
97101
bottomMostRow = Math.max(
98102
bottomMostRow,
99-
rowStart + rowSpan - 1
103+
parseInt( newRowStart, 10 ) + parseInt( rowSpan, 10 ) - 1
100104
);
101105
}
102106
if ( ! rowCount || rowCount < bottomMostRow ) {

0 commit comments

Comments
 (0)