Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: do not stop ignored dragleave events in grid #8500

Merged
merged 2 commits into from
Jan 13, 2025
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
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