Skip to content

Commit 1ff1f42

Browse files
authored
Merge pull request #2461 from akosfekete/2394_fix
Remove added node from layout cache on drop event
2 parents 121fa2f + 1842aa0 commit 1ff1f42

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/gridstack-engine.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,17 @@ export class GridStackEngine {
958958
return this._layouts?.[column]?.findIndex(l => l._id === n._id) ?? -1;
959959
}
960960

961+
public removeNodeFromLayoutCache(n: GridStackNode) {
962+
if (!this._layouts) {
963+
return;
964+
}
965+
for (let i = 0; i < this._layouts.length; i++) {
966+
let index = this.findCacheLayout(n, i);
967+
if (index !== -1) {
968+
this._layouts[i].splice(index, 1);
969+
}
970+
}
971+
}
961972

962973
/** called to remove all internal values but the _id */
963974
public cleanupNode(node: GridStackNode): GridStackEngine {

src/gridstack.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,6 +2141,7 @@ export class GridStack {
21412141
this._updateContainerHeight();
21422142
this.engine.addedNodes.push(node);// @ts-ignore
21432143
this._triggerAddEvent();// @ts-ignore
2144+
this.engine.removeNodeFromLayoutCache(node);
21442145
this._triggerChangeEvent();
21452146

21462147
this.engine.endUpdate();

0 commit comments

Comments
 (0)