diff --git a/packages/grid/src/vaadin-grid-drag-and-drop-mixin.js b/packages/grid/src/vaadin-grid-drag-and-drop-mixin.js index 7f489bec0f0..dbc68c32dca 100644 --- a/packages/grid/src/vaadin-grid-drag-and-drop-mixin.js +++ b/packages/grid/src/vaadin-grid-drag-and-drop-mixin.js @@ -234,6 +234,9 @@ export const DragAndDropMixin = (superClass) => /** @private */ _onDragLeave(e) { + if (!this.dropMode) { + return; + } e.stopPropagation(); this._clearDragStyles(); } diff --git a/packages/grid/test/drag-and-drop.common.js b/packages/grid/test/drag-and-drop.common.js index 64a6c22d1ff..3018c1674b2 100644 --- a/packages/grid/test/drag-and-drop.common.js +++ b/packages/grid/test/drag-and-drop.common.js @@ -403,6 +403,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', () => { @@ -412,8 +414,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; }); @@ -636,12 +646,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();