Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
chioio opened this issue Sep 16, 2022 · 9 comments

Comments

@chioio
Copy link

chioio commented Sep 16, 2022

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

@jianqiao0313
Copy link

+1

@syropian
Copy link

syropian commented Sep 26, 2022

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

@Kevin123X
Copy link

how to reslove

@Quasarman
Copy link

Has anyone resolved this issue?

@ajdvoynos
Copy link

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
Copy link

Duplicate of #159

@vedmant
Copy link

vedmant commented Dec 12, 2022

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

@ErhardScampi
Copy link

ErhardScampi commented Feb 12, 2023

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.....

@hugegegewu
Copy link

hugegegewu commented Feb 14, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants