From 3dd3266f7a12d98ad61cc9e5a599b62d44de00ec Mon Sep 17 00:00:00 2001 From: Filip Kujavec Date: Wed, 11 Jun 2025 10:50:54 +0200 Subject: [PATCH 1/3] fix: makeWidget breakpoint layout issue --- src/gridstack-engine.ts | 4 ++-- src/gridstack.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gridstack-engine.ts b/src/gridstack-engine.ts index 02a7bf2fd..0f0c08ac1 100644 --- a/src/gridstack-engine.ts +++ b/src/gridstack-engine.ts @@ -417,14 +417,14 @@ export class GridStackEngine { // remember it's position & width so we can restore back (1 -> 12 column) #1655 #1985 // IFF we're not in the middle of column resizing! const saveOrig = (node.x || 0) + (node.w || 1) > this.column; - if (saveOrig && this.column < this.defaultColumn && !this._inColumnResize && !this.skipCacheUpdate && node._id && this.findCacheLayout(node, this.defaultColumn) === -1) { + if (saveOrig && this.column < this.defaultColumn && !this._inColumnResize && !this.skipCacheUpdate && !isNaN(node._id) && this.findCacheLayout(node, this.defaultColumn) === -1) { const copy = {...node}; // need _id + positions if (copy.autoPosition || copy.x === undefined) { delete copy.x; delete copy.y; } else copy.x = Math.min(this.defaultColumn - 1, copy.x); copy.w = Math.min(this.defaultColumn, copy.w || 1); this.cacheOneLayout(copy, this.defaultColumn); } - + if (node.w > this.column) { node.w = this.column; } else if (node.w < 1) { diff --git a/src/gridstack.ts b/src/gridstack.ts index 3ca758fc4..db614c97c 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -1633,7 +1633,9 @@ export class GridStack { el.gridstackNode = node; node.el = el; node.grid = this; + this.engine._loading = true; // help with collision node = this.engine.addNode(node, triggerAddEvent); + delete this.engine._loading; // done loading // write the dom sizes and class this._writeAttr(el, node); From 0929656600c12db9cfc045a4593662bfe0519f01 Mon Sep 17 00:00:00 2001 From: Filip Kujavec Date: Thu, 12 Jun 2025 07:25:18 +0200 Subject: [PATCH 2/3] fix: needs more debugging --- src/gridstack.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gridstack.ts b/src/gridstack.ts index db614c97c..3ca758fc4 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -1633,9 +1633,7 @@ export class GridStack { el.gridstackNode = node; node.el = el; node.grid = this; - this.engine._loading = true; // help with collision node = this.engine.addNode(node, triggerAddEvent); - delete this.engine._loading; // done loading // write the dom sizes and class this._writeAttr(el, node); From 4f9562035582ea0dfb07c6aa1b0a4b3ac680ef53 Mon Sep 17 00:00:00 2001 From: Filip Kujavec Date: Fri, 20 Jun 2025 12:37:29 +0200 Subject: [PATCH 3/3] fix: more generic node._id check --- src/gridstack-engine.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gridstack-engine.ts b/src/gridstack-engine.ts index 0f0c08ac1..b41a404b9 100644 --- a/src/gridstack-engine.ts +++ b/src/gridstack-engine.ts @@ -417,7 +417,7 @@ export class GridStackEngine { // remember it's position & width so we can restore back (1 -> 12 column) #1655 #1985 // IFF we're not in the middle of column resizing! const saveOrig = (node.x || 0) + (node.w || 1) > this.column; - if (saveOrig && this.column < this.defaultColumn && !this._inColumnResize && !this.skipCacheUpdate && !isNaN(node._id) && this.findCacheLayout(node, this.defaultColumn) === -1) { + if (saveOrig && this.column < this.defaultColumn && !this._inColumnResize && !this.skipCacheUpdate && (node._id ?? false) && this.findCacheLayout(node, this.defaultColumn) === -1) { const copy = {...node}; // need _id + positions if (copy.autoPosition || copy.x === undefined) { delete copy.x; delete copy.y; } else copy.x = Math.min(this.defaultColumn - 1, copy.x);