From 9c39de5b10e88503ff7aaed49f63b431212a6bc9 Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Mon, 31 Aug 2026 22:53:54 -0400 Subject: [PATCH] fix(interactions): ignore secondary-button cell range drags --- .../e2e/example-plugin-hybridselectionmodel.cy.ts | 15 +++++++++++++++ src/slick.interactions.ts | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/cypress/e2e/example-plugin-hybridselectionmodel.cy.ts b/cypress/e2e/example-plugin-hybridselectionmodel.cy.ts index ae0d83e1..79bfdd0c 100644 --- a/cypress/e2e/example-plugin-hybridselectionmodel.cy.ts +++ b/cypress/e2e/example-plugin-hybridselectionmodel.cy.ts @@ -32,6 +32,21 @@ describe('Example - Context Menu Plugin & Hybrid Selection Mode', () => { cy.get('#myGrid .slick-cell.selected').should('have.length', 4); }); + it('should preserve cell selection when dragging with the secondary mouse button', () => { + cy.get('#myGrid .slick-cell.selected').should('have.length', 4); + + cy.get('#myGrid .slick-row[data-row="1"] .slick-cell.l1.r1').trigger('mousedown', { + button: 2, + which: 3, + force: true, + }); + cy.get('#myGrid .slick-row[data-row="3"] .slick-cell.l3.r3') + .trigger('mousemove', 'bottomRight') + .trigger('mouseup', 'bottomRight', { button: 2, which: 3, force: true }); + + cy.get('#myGrid .slick-cell.selected').should('have.length', 4); + }); + it('should be able to expand the cell selections further to the right', () => { cy.get('#myGrid .slick-cell.selected').should('have.length', 4); cy.get('#myGrid .slick-row[data-row="2"] .slick-cell.l2.r2') diff --git a/src/slick.interactions.ts b/src/slick.interactions.ts index f35897f6..612e8aaf 100644 --- a/src/slick.interactions.ts +++ b/src/slick.interactions.ts @@ -84,6 +84,13 @@ export function Draggable(options: DraggableOption) { } function userPressed(event: MouseEvent | TouchEvent | KeyboardEvent) { + // Dragging is a primary-button action; allow secondary clicks to continue + // to context-menu handling without starting a drag. + // Keep synthetic mousedown CustomEvents compatible (they have no `button`). + if (event.type === 'mousedown' && 'button' in event && (event as MouseEvent).button !== 0) { + return; + } + if (!preventDrag(event)) { element = event.target as HTMLElement; const targetEvent: MouseEvent | Touch = (event as TouchEvent)?.touches?.[0] ?? event;