Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cypress/e2e/example-plugin-hybridselectionmodel.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
7 changes: 7 additions & 0 deletions src/slick.interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading