Skip to content

fix(drag-drop): disable drag on secondary pointer button - 22.0.x - #17522

Open
igdmdimitrov wants to merge 1 commit into
22.0.xfrom
dmdimitrov/fix-17424-22.0.x
Open

fix(drag-drop): disable drag on secondary pointer button - 22.0.x#17522
igdmdimitrov wants to merge 1 commit into
22.0.xfrom
dmdimitrov/fix-17424-22.0.x

Conversation

@igdmdimitrov

Copy link
Copy Markdown
Contributor

Closes #17424

Description

Modifying drag-drop directive to start drag only on primary mouse button

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

Copilot AI lite review requested due to automatic review settings August 24, 2026 15:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #17424 by preventing IgxDragDirective from initiating drag interactions when the user presses a non-primary pointer button (e.g., right click), which previously could trigger drag/click behavior and then show the browser context menu.

Changes:

  • Added an early-return guard in IgxDragDirective.onPointerDown to only start drag handling for the primary button.
  • Added a unit test to verify that a secondary-button pointerdown does not start dragging, emit drag events, or create a ghost element.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts Adds a primary-button check in onPointerDown to prevent drag initiation on secondary button presses.
projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.spec.ts Adds coverage to ensure secondary-button pointer input does not initiate drag/click behavior.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +2006 to +2010
it('should not initiate drag on secondary pointer button', async () => {
const firstDrag = fix.componentInstance.dragElems.first;
const firstElement = firstDrag.element.nativeElement;
const startingX = (dragDirsRects[0].left + dragDirsRects[0].right) / 2;
const startingY = (dragDirsRects[0].top + dragDirsRects[0].bottom) / 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants