Skip to content

Commit

Permalink
fix: allow to drop on items that cannot be dragged
Browse files Browse the repository at this point in the history
  • Loading branch information
jledentu committed Sep 16, 2024
1 parent 5468685 commit 52d8411
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/FinderItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default {
this.treeModel.startDrag(this.node.id);
},
onDragOver(event) {
if (!this.canDrag) {
if (!this.dragEnabled) {
return;
}
Expand All @@ -182,7 +182,7 @@ export default {
this.ghost.parentNode.removeChild(this.ghost);
this.ghost = null;
}
if (!this.canDrag) {
if (!this.dragEnabled) {
return;
}
Expand Down
20 changes: 20 additions & 0 deletions src/components/__tests__/FinderItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,26 @@ describe("FinderItem", () => {

expect(dataTransfer.dropEffect).toBeUndefined();
});

it("should set dataTransfer.dropEffect = `all` if `dragEnabled` is a function returning `false`", async () => {
const dataTransfer = {};
const wrapper = mount(FinderItem, {
propsData: {
treeModel,
node,
dragEnabled: () => false,
options: {
canDrop: () => true
}
}
});

await wrapper.trigger("dragover", {
dataTransfer
});

expect(dataTransfer.dropEffect).toBe("move");
});
});

describe("dragend", () => {
Expand Down

0 comments on commit 52d8411

Please sign in to comment.