Skip to content

Commit 6943f09

Browse files
committed
fix: prevent context menu event while dragging
1 parent 9b0956a commit 6943f09

File tree

1 file changed

+7
-0
lines changed
  • src/components/common/controllers

1 file changed

+7
-0
lines changed

src/components/common/controllers/drag.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,15 @@ class DragController implements ReactiveController {
193193
this._host.addEventListener('dragstart', this);
194194
this._host.addEventListener('touchstart', this, { passive: false });
195195
this._host.addEventListener('pointerdown', this);
196+
globalThis.addEventListener('contextmenu', this._handleContextMenu);
196197
}
197198

198199
/** @internal */
199200
public hostDisconnected(): void {
200201
this._host.removeEventListener('dragstart', this);
201202
this._host.removeEventListener('touchstart', this);
202203
this._host.removeEventListener('pointerdown', this);
204+
globalThis.removeEventListener('contextmenu', this._handleContextMenu);
203205
this._setDragCancelListener(false);
204206
this._removeGhost();
205207
}
@@ -284,6 +286,11 @@ class DragController implements ReactiveController {
284286
}
285287
}
286288

289+
private _handleContextMenu(event: MouseEvent): void {
290+
// Prevents the default context menu while dragging
291+
event.preventDefault();
292+
}
293+
287294
// #endregion
288295

289296
private _setDragCancelListener(enabled = true): void {

0 commit comments

Comments
 (0)