SortableJS / vue.draggable.next

Vue 3 compatible drag-and-drop component based on Sortable.js
https://sortablejs.github.io/vue.draggable.next/#/simple
MIT License
3.91k stars 531 forks source link

Problem creating slot inside "item" slot #196

Open GuilhermeErmel opened 1 year ago

GuilhermeErmel commented 1 year ago

Description

When I create my own draggable component using a slot inside the slot named "item", the draggable functionality doesn't work.

This is a bug or I'm doing something wrong?

codesandbox link

https://codesandbox.io/s/strange-sammet-6icdhq?file=/src/components/MyDraggable.vue:69-74

Lionad-Morotar commented 1 year ago

Hi,Im guessing you need this:Code Sandbox Playground,and vue dynamic slot names

cpannwitz commented 1 year ago

I just had the same problem, seems like sortablejs can't create the appropriate data tags on a slot (data-draggable="true").

Workaround would be to create an additional component in the slot:

<draggable
 ... attributes ...
>
    <template #item="dragProps">
      <div> <------------- NEEDS THIS !
        <slot v-bind="dragProps" />
      </div>
    </template>
</draggable>
alecgibson commented 1 year ago

It also doesn't seem to play nicely if your draggable=".foo" prop targets an element inside the nested slot

1985chen commented 1 year ago

Did you solve it?

belxiors commented 7 months ago

Any news on this? @cpannwitz solution does not work for me, as I am using this inside a table and a div would not fit.

Thanks!