vue.draggable.next icon indicating copy to clipboard operation
vue.draggable.next copied to clipboard

Official example: Cannot set properties of null (setting '__draggable_context')

Open chioio opened this issue 2 years ago • 9 comments

First check https://github.com/SortableJS/Vue.Draggable/blob/master/CONTRIBUTING.md

Jsfiddle link

Step by step scenario

Copy vue.draggable.next transition example in vue 3 project. Run... Err!!! image

chioio avatar Sep 16 '22 03:09 chioio

+1

jianqiao0313 avatar Sep 23 '22 08:09 jianqiao0313

Also running in to this on a Vue 3 project (on ^4.1.0)

syropian avatar Sep 26 '22 14:09 syropian

how to reslove

Kevin123X avatar Sep 27 '22 08:09 Kevin123X

Has anyone resolved this issue?

Quasarman avatar Oct 17 '22 17:10 Quasarman

This only seems to happen with Vue versions 3.2.32 and above. It also explains why the deployed sample seems to work fine. If the maintainer were to update the package.lock.json, then it would stop working.

A workaround I've found so far is to NOT use the tag prop, but instead pass the TransitionGroup in the componentData prop, like so:

<template>
    <Draggable 
        v-model="myArray" 
        itemKey="id" 
        :componentData="{ 
            tag: 'div', 
            type: 'transition-group'
        }">
        <template #item="{element}">
            <div>{{element.label}}</div>
        </template>
    </Draggable>
</template>
<script setup>
import {ref} from 'vue';
import Draggable from 'vuedraggable'
const myArray = ref([
    {
        id: 3,
        label: 'third'
    },
    {
        id: 1,
        label: 'first'
    },
    {
        id: 2,
        label: 'second'
    }
])
</script>

ajdvoynos avatar Oct 25 '22 16:10 ajdvoynos

Duplicate of #159

ajdvoynos avatar Oct 25 '22 17:10 ajdvoynos

@ajdvoynos This doesn't work for tables, it's not allowing to set tag: 'tbody, , always renders div.

vedmant avatar Dec 12 '22 22:12 vedmant

tag="transition-group" is outside the component data in the example

https://github.com/SortableJS/vue.draggable.next/tree/master/example/components)/transition-example-2.vue

<draggable class="list-group" tag="transition-group" :component-data="{ tag: 'ul', type: 'transition-group', name: !drag ? 'flip-list' : null }" v-model="list"

if you delete tag="transition-group". it works even with script-setup syntax : By the way I do not know for what purpose is tag="transition-group" Using Quasar 3.7.1

Indeed tag is ignored its always a div but it does not matter at the moment I put the q-card in the template.....

ErhardScampi avatar Feb 12 '23 15:02 ErhardScampi

tag="transition-group" is outside the component data in the example

https://github.com/SortableJS/vue.draggable.next/tree/master/example/components)/transition-example-2.vue

<draggable class="list-group" tag="transition-group" :component-data="{ tag: 'ul', type: 'transition-group', name: !drag ? 'flip-list' : null }" v-model="list"

if you delete tag="transition-group". it works even with script-setup syntax : By the way I do not know for what purpose is tag="transition-group" Using Quasar 3.7.1

Indeed tag is ignored its always a div but it does not matter at the moment I put the q-card in the template.....

You are right! It had confused me over several hours. Thank you very much!

hugegegewu avatar Feb 14 '23 15:02 hugegegewu