Skip to content

Commit

Permalink
fix: do not stop ignored dragleave events in grid (#8500) (#8502)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomi Virkki <[email protected]>
  • Loading branch information
vaadin-bot and tomivirkki authored Jan 13, 2025
1 parent 476bd75 commit 5a621c4
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 @@ -234,6 +234,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 @@ -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', () => {
Expand All @@ -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;
});
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 5a621c4

Please sign in to comment.