Skip to content

Commit 276e107

Browse files
authored
Merge pull request #3072 from FilipKujavec/fix/#3071-layout-breaks-when-initilized-with-one-column
fix: makeWidget breakpoint layout issue #3071
2 parents b839db9 + 4f95620 commit 276e107

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/gridstack-engine.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,14 @@ export class GridStackEngine {
417417
// remember it's position & width so we can restore back (1 -> 12 column) #1655 #1985
418418
// IFF we're not in the middle of column resizing!
419419
const saveOrig = (node.x || 0) + (node.w || 1) > this.column;
420-
if (saveOrig && this.column < this.defaultColumn && !this._inColumnResize && !this.skipCacheUpdate && node._id && this.findCacheLayout(node, this.defaultColumn) === -1) {
420+
if (saveOrig && this.column < this.defaultColumn && !this._inColumnResize && !this.skipCacheUpdate && (node._id ?? false) && this.findCacheLayout(node, this.defaultColumn) === -1) {
421421
const copy = {...node}; // need _id + positions
422422
if (copy.autoPosition || copy.x === undefined) { delete copy.x; delete copy.y; }
423423
else copy.x = Math.min(this.defaultColumn - 1, copy.x);
424424
copy.w = Math.min(this.defaultColumn, copy.w || 1);
425425
this.cacheOneLayout(copy, this.defaultColumn);
426426
}
427-
427+
428428
if (node.w > this.column) {
429429
node.w = this.column;
430430
} else if (node.w < 1) {

0 commit comments

Comments
 (0)