Skip to content

Commit 38ce7d7

Browse files
author
Jesper Hermann Munk
committed
Fixed this touch issue happening on Linux device with touch screen running the application under Electron:
When user starts dragging an item, as soon finger leaves the element, _mouseLeave is run, called from @dd-touch.js simulating mouse event. But on next move, _mouseEnter is run even though pointer has not reentered the element. _mouseEnter is not called by @dd-touch.js as part of simulating mouse, but is called as a real mouse event by browser. Strange part is that event.screenX from the _mouseEvent argument, gives a coordinate that matches where finger started dragging, not the coordinate of where the finger left the element.
1 parent 9e60b95 commit 38ce7d7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/dd-droppable.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ export class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt
8888
protected _mouseEnter(e: MouseEvent): void {
8989
// console.log(`${count++} Enter ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST
9090
if (!DDManager.dragElement) return;
91+
// During touch drag operations, ignore real browser-generated mouseenter events (isTrusted: true).
92+
// Only process simulated mouseenter events (isTrusted: false) created by our touch handling code.
93+
// The browser can fire spurious mouseenter events when we dispatch simulated mousemove events.
94+
if (isTouch && e.isTrusted) {
95+
return
96+
}
9197
if (!this._canDrop(DDManager.dragElement.el)) return;
9298
e.preventDefault();
9399
e.stopPropagation();

0 commit comments

Comments
 (0)