Skip to content

Commit

Permalink
fix: do not stop ignored dragleave events in grid (#8500)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki committed Jan 13, 2025
1 parent af1a9d8 commit 3d7290e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/grid/src/vaadin-grid-drag-and-drop-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ export const DragAndDropMixin = (superClass) =>

/** @private */
_onDragLeave(e) {
if (!this.dropMode) {
return;
}
e.stopPropagation();
this._clearDragStyles();
}
Expand Down
20 changes: 19 additions & 1 deletion packages/grid/test/drag-and-drop.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ describe('drag and drop', () => {
beforeEach(() => {
dragEndSpy = sinon.spy();
listenOnce(grid, 'grid-dragend', dragEndSpy);
grid.selectedItems = grid.items;
fireDragStart();
});

it('should stop the native event', () => {
Expand All @@ -381,8 +383,16 @@ describe('drag and drop', () => {
expect(spy.called).to.be.false;
});

it('should not stop the native event on grid itself', () => {
fireDragEnd();

const spy = sinon.spy();
listenOnce(grid, 'dragend', spy);
fireDragEnd(grid);
expect(spy.called).to.be.true;
});

it('should remove dragging state attribute', () => {
fireDragStart();
fireDragEnd();
expect(grid.hasAttribute('dragging-rows')).to.be.false;
});
Expand Down Expand Up @@ -605,12 +615,20 @@ describe('drag and drop', () => {

describe('dragleave', () => {
it('should stop the native event', () => {
grid.dropMode = 'on-grid';
const spy = sinon.spy();
listenOnce(grid, 'dragleave', spy);
fireDragLeave();
expect(spy.called).to.be.false;
});

it('should not stop the native event if grid has no drop mode', () => {
const spy = sinon.spy();
listenOnce(grid, 'dragleave', spy);
fireDragLeave();
expect(spy.called).to.be.true;
});

it('should clear the grid dragover attribute', () => {
grid.dropMode = 'on-grid';
fireDragOver();
Expand Down

0 comments on commit 3d7290e

Please # to comment.