Skip to content

Commit 5933a38

Browse files
tepitomivirkki
andauthored
fix: do not stop ignored dragleave events in grid (#8500) (#8640)
Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com>
1 parent df13756 commit 5933a38

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

packages/grid/src/vaadin-grid-drag-and-drop-mixin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ export const DragAndDropMixin = (superClass) =>
208208

209209
/** @private */
210210
_onDragLeave(e) {
211+
if (!this.dropMode) {
212+
return;
213+
}
211214
e.stopPropagation();
212215
this._clearDragStyles();
213216
}

packages/grid/test/drag-and-drop.test.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ describe('drag and drop', () => {
350350
beforeEach(() => {
351351
dragEndSpy = sinon.spy();
352352
listenOnce(grid, 'grid-dragend', dragEndSpy);
353+
grid.selectedItems = grid.items;
354+
fireDragStart();
353355
});
354356

355357
it('should stop the native event', () => {
@@ -359,8 +361,16 @@ describe('drag and drop', () => {
359361
expect(spy.called).to.be.false;
360362
});
361363

364+
it('should not stop the native event on grid itself', () => {
365+
fireDragEnd();
366+
367+
const spy = sinon.spy();
368+
listenOnce(grid, 'dragend', spy);
369+
fireDragEnd(grid);
370+
expect(spy.called).to.be.true;
371+
});
372+
362373
it('should remove dragging state attribute', () => {
363-
fireDragStart();
364374
fireDragEnd();
365375
expect(grid.hasAttribute('dragging-rows')).to.be.false;
366376
});
@@ -511,13 +521,21 @@ describe('drag and drop', () => {
511521

512522
describe('dragleave', () => {
513523
it('should stop the native event', () => {
524+
grid.dropMode = 'on-grid';
514525
const spy = sinon.spy();
515526
listenOnce(grid, 'dragleave', spy);
516527
fireDragLeave();
517528
expect(spy.called).to.be.false;
518529
});
519530

520-
it('should clear the grid drag styles', () => {
531+
it('should not stop the native event if grid has no drop mode', () => {
532+
const spy = sinon.spy();
533+
listenOnce(grid, 'dragleave', spy);
534+
fireDragLeave();
535+
expect(spy.called).to.be.true;
536+
});
537+
538+
it('should clear the grid dragover attribute', () => {
521539
grid.dropMode = 'on-grid';
522540
fireDragOver();
523541
expect(grid.hasAttribute('dragover')).to.be.true;

0 commit comments

Comments
 (0)