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

Draggable doesnt work with slot inside tempate #item #24

Closed jenjen75 closed 3 years ago

jenjen75 commented 3 years ago

When working with slot inside tempate #item, draggable doesnt work. Slot elements are rendered but I cannot drag & drop

  <draggable
    v-model="myArray"
    group="people"
    @start="drag = true"
    @end="drag = false"
    item-key="id"
  >
    <template #item="{ element }">
        <slot name="default" v-bind="{ element }" />
    </template>
  </draggable>

As workaround, I wrap into slot a div to make it work.

  <draggable
    v-model="myArray"
    group="people"
    @start="drag = true"
    @end="drag = false"
    item-key="id"
  >
    <template #item="{ element }">
      <div>
        <slot name="default" v-bind="{ item: element }" />
      </div>
    </template>
  </draggable>

Sorry for not providing jsfiddle, I can't generate (see #23 )

David-Desmaisons commented 3 years ago

Item should be element with only one root, this is why you need to add the extra div. Consider it as a permanent limitation.

Hakityc commented 5 months ago

it's work! Thanks