Skip to content

Commit 1842aa0

Browse files
committed
Remove added node from layout cache on drop event
1 parent 768b8ef commit 1842aa0

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
@@ -2135,6 +2135,7 @@ export class GridStack {
21352135
this._updateContainerHeight();
21362136
this.engine.addedNodes.push(node);// @ts-ignore
21372137
this._triggerAddEvent();// @ts-ignore
2138+
this.engine.removeNodeFromLayoutCache(node);
21382139
this._triggerChangeEvent();
21392140

21402141
this.engine.endUpdate();

0 commit comments

Comments
 (0)