From 52d8411064571d1df5856e48b38ef2861352d0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Ledentu?= Date: Mon, 16 Sep 2024 16:44:48 +0200 Subject: [PATCH] fix: allow to drop on items that cannot be dragged --- src/components/FinderItem.vue | 4 ++-- src/components/__tests__/FinderItem.test.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/components/FinderItem.vue b/src/components/FinderItem.vue index e63c166..2774e40 100644 --- a/src/components/FinderItem.vue +++ b/src/components/FinderItem.vue @@ -165,7 +165,7 @@ export default { this.treeModel.startDrag(this.node.id); }, onDragOver(event) { - if (!this.canDrag) { + if (!this.dragEnabled) { return; } @@ -182,7 +182,7 @@ export default { this.ghost.parentNode.removeChild(this.ghost); this.ghost = null; } - if (!this.canDrag) { + if (!this.dragEnabled) { return; } diff --git a/src/components/__tests__/FinderItem.test.js b/src/components/__tests__/FinderItem.test.js index c21bf4c..6455826 100644 --- a/src/components/__tests__/FinderItem.test.js +++ b/src/components/__tests__/FinderItem.test.js @@ -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", () => {