Skip to content

Commit

Permalink
fix: drag handle
Browse files Browse the repository at this point in the history
  • Loading branch information
jledentu committed Aug 22, 2022
1 parent f26c98f commit db1f740
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 0 additions & 2 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ module.exports = {
path.resolve(__dirname, "../vite.config.js")
);

console.log(JSON.stringify(config));

return {
...config,
define: {
Expand Down
8 changes: 3 additions & 5 deletions src/components/FinderItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
node.cssClass || '',
{
expanded,
draggable: dragEnabled && (!options.hasDragHandle || dragHandleOver),
draggable: dragEnabled && !options.hasDragHandle,
dragged,
'has-drag-handle': dragEnabled && options.hasDragHandle,
'drag-over': dragOver,
Expand All @@ -29,7 +29,7 @@
...(dragOver &&
theme.dropZoneBgColor && { backgroundColor: theme.dropZoneBgColor }),
}"
:draggable="dragEnabled && !options.hasDragHandle"
:draggable="dragEnabled && (!options.hasDragHandle || dragHandleOver)"
:aria-expanded="node.isLeaf ? undefined : expanded"
v-bind="$attrs"
@mousedown="onMouseDown"
Expand Down Expand Up @@ -207,9 +207,7 @@ export default {
return;
}
if (this.options.hasDragHandle) {
this.$el.setAttribute("draggable", "false");
}
this.dragHandleOver = false;
this.treeModel.stopDrag();
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/__tests__/FinderItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,10 @@ describe("FinderItem", () => {
});

await wrapper.find(".drag-handle").trigger("mousedown");
expect(wrapper.find(".item").classes()).toContain("draggable");
expect(wrapper.find(".item").attributes("draggable")).toBe("true");

await wrapper.find(".drag-handle").trigger("mouseup");
expect(wrapper.find(".item").classes()).not.toContain("draggable");
expect(wrapper.find(".item").attributes("draggable")).toBe("false");
});

it("should remove ghost element if 'dragImageComponent' is defined", async () => {
Expand Down

0 comments on commit db1f740

Please sign in to comment.