Skip to content

Commit 164f6b6

Browse files
committed
nested grid fix #2560
* tweak to prev fix.
1 parent 3ea8fbe commit 164f6b6

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

doc/CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ Change log
110110
## 10.0.1-dev (TBD)
111111
* feat: [#2574](https://github.com/gridstack/gridstack.js/pull/2574) Allow cell height in cm and mm units
112112
* fix: [#2577](https://github.com/gridstack/gridstack.js/issues/2577) ui-resizable-s/-n style fix
113-
* fix: [#2578](https://github.com/gridstack/gridstack.js/issues/2578) column('none') now ignores layouts
113+
* fix: [#2576](https://github.com/gridstack/gridstack.js/issues/2576) column('none') now ignores layouts
114+
* fix: [#2560](https://github.com/gridstack/gridstack.js/issues/2560) nested grid fix (enter can call leave which can call enter again).
114115

115116
## 10.0.1 (2023-12-10)
116117
* fix: [#2552](https://github.com/gridstack/gridstack.js/issues/2552) DOM init doesn't sizeToContent

src/dd-droppable.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt
9494

9595
// make sure when we enter this, that the last one gets a leave FIRST to correctly cleanup as we don't always do
9696
if (DDManager.dropElement && DDManager.dropElement !== this) {
97-
DDManager.dropElement._mouseLeave(e as DragEvent, true);
97+
DDManager.dropElement._mouseLeave(e as DragEvent, true); // calledByEnter = true
9898
}
9999
DDManager.dropElement = this;
100100

@@ -108,7 +108,7 @@ export class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt
108108
}
109109

110110
/** @internal called when the item is leaving our area, stop tracking if we had moving item */
111-
protected _mouseLeave(e: MouseEvent, external = false): void {
111+
protected _mouseLeave(e: MouseEvent, calledByEnter = false): void {
112112
// console.log(`${count++} Leave ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST
113113
if (!DDManager.dragElement || DDManager.dropElement !== this) return;
114114
e.preventDefault();
@@ -120,19 +120,21 @@ export class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt
120120
}
121121
this.triggerEvent('dropout', ev);
122122

123-
if (!external && DDManager.dropElement === this) {
123+
if (DDManager.dropElement === this) {
124124
delete DDManager.dropElement;
125125
// console.log('not tracking'); // TEST
126126

127127
// if we're still over a parent droppable, send it an enter as we don't get one from leaving nested children
128-
let parentDrop: DDDroppable;
129-
let parent: DDElementHost = this.el.parentElement;
130-
while (!parentDrop && parent) {
131-
parentDrop = parent.ddElement?.ddDroppable;
132-
parent = parent.parentElement;
133-
}
134-
if (parentDrop) {
135-
parentDrop._mouseEnter(e);
128+
if (!calledByEnter) {
129+
let parentDrop: DDDroppable;
130+
let parent: DDElementHost = this.el.parentElement;
131+
while (!parentDrop && parent) {
132+
parentDrop = parent.ddElement?.ddDroppable;
133+
parent = parent.parentElement;
134+
}
135+
if (parentDrop) {
136+
parentDrop._mouseEnter(e);
137+
}
136138
}
137139
}
138140
}

0 commit comments

Comments
 (0)