vue.draggable.next: TypeError: Cannot set properties of null (setting '__draggable_context')
Hello,
I am getting the following error when my page loads:
TypeError: Cannot set properties of null (setting '__draggable_context')
at addContext (node_modules\vuedraggable\dist\vuedraggable.umd.js:4478:1)
at eval (node_modules\vuedraggable\dist\vuedraggable.umd.js:4523:1)
at Array.forEach (<anonymous>)
at ComponentStructure.updated (node_modules\vuedraggable\dist\vuedraggable.umd.js:4522:1)
at Proxy.updated (node_modules\vuedraggable\dist\vuedraggable.umd.js:4829:1)
at callWithErrorHandling (node_modules\@vue\runtime-core\dist\runtime-core.esm-bundler.js:155:1)
at callWithAsyncErrorHandling (node_modules\@vue\runtime-core\dist\runtime-core.esm-bundler.js:164:1)
at Array.hook.__weh.hook.__weh (node_modules\@vue\runtime-core\dist\runtime-core.esm-bundler.js:2685:1)
at flushPostFlushCbs (node_modules\@vue\runtime-core\dist\runtime-core.esm-bundler.js:356:1)
at flushJobs (node_modules\@vue\runtime-core\dist\runtime-core.esm-bundler.js:401:1)
I cannot drag anything, when I try to drag I get the following error:
node_modules\vuedraggable\dist\vuedraggable.umd.js:4974 Uncaught TypeError: Cannot read properties of null (reading 'index')
at Proxy.onDragUpdate (node_modules\vuedraggable\dist\vuedraggable.umd.js:4974:1)
at Proxy.eval (node_modules\vuedraggable\dist\vuedraggable.umd.js:4694:1)
at Sortable.eval (node_modules\vuedraggable\dist\vuedraggable.umd.js:4705:1)
at dispatchEvent (node_modules\sortablejs\modular\sortable.esm.js:916:1)
at _dispatchEvent (node_modules\sortablejs\modular\sortable.esm.js:961:1)
at Sortable._onDrop (node_modules\sortablejs\modular\sortable.esm.js:2216:1)
at Sortable.handleEvent (node_modules\sortablejs\modular\sortable.esm.js:2269:1)
at Sortable.__trace__ [as handleEvent] (node_modules\@bugsnag\browser\dist\bugsnag.js:2764:1)
I have tried downgrading to versions 4.0.1 as well as version 4.0.0 and both still throw the error. This is my component:
<draggable item-key="id" v-model="person" handle=".gripIcon" @start="drag=true" @end="drag=false" tag="transition-group" :component-data="{name:'flip-list'}">
<template #item="{element,index}">
<component :is="element.name" :id="element.id"
v-bind:key="element.id"
v-on:delete-row="deleteRow(index)"
v-on:update-info="data => updateInfo(index,data)">
</component>
</template>
</draggable>
Please assist.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 39
- Comments: 39
Commits related to this issue
- fix: replace vue.draggable.next with zhyswan-draggable Reason: Author doesn't maintain vue port anymore. See: https://github.com/SortableJS/vue.draggable.next/issues/140#issuecomment-1123622724= — committed to go-vikunja/frontend by dpschen 2 years ago
- fix #140 empty context — committed to danielsussa/vue.draggable.next by danielsussa a year ago
Guys… for me its working with simply removing tag=“transition-group” and using v-bind=“dragOptions”
after that remember remove any transitions effect you have in your css for the dragged element.
I was able to get rid of the error by removing
tag="transition-group"
but still keep a nice transition by adding the prop:animation="150"
what a pity,i remove
tag="transition-group"
in order to work you have to downgrade your vue and that solves it. go to 3.2.30
我使用了: “vue”: “^3.2.25” “vite”: “^2.8.0” “vuedraggable”: “^4.1.0”
近期重新install或update后发现了bug,通过移除 tag=“transition-group” 后解决了此问题
Removing the tag=“transition-group” worked for me. I no longer get the error. Kinda sad though cause now there’s no more smooth transitions when dragging and swapping items!
I noticed the authors own code examples don’t even work. I think he needs to update them.
I was having this same issue and published a thin wrapper around
sortablejs
that seems to work more consistently. Feel free to try it out and leave feedback at https://github.com/MaxLeiter/sortablejs-vue3.Thanks @ceciogit This also worked for me 👍
This error did not happen to me before and started to happen when I performed an
npm update
. The error was fixed by setting vue to version3.2.30
currently3.2.33
"vue": "3.2.30",
Will the official fix this problem? I see that the last version is still released in 2020
I can second @danielkellyio. I conclude that just the documentation is out of date.
I was working along the official example, and @danielkellyio’s proposal fixed the issue for me. Not even any additional CSS transition styles are required with this solution. Probably the author made all that inline now.
For completeness, here is my current working state: https://github.com/suterma/replayer-pwa/blob/fe4e71f58c853a7f016ccee0056dd917c94882ef/src/views/Setlist.vue#L63
不能说解决吧,只能说用这个办法可以通过移除特性的方式避开这个 bug ,我觉得如果这个仓库官方不打算维护了,将 vue-draggable 替换为 sortable 才是最合适的方案,因为 vue-draggable 内核也是基于 sortable 开发的
Created a simple PR, 3 lines… https://github.com/SortableJS/vue.draggable.next/pull/207
In my case, it´s necessary using
tag="transition-group"
…Removing “transition-group” and usign animation prop works for having smooth transitions, yes. BUT if the data changes, (for example on a undo action), there is no animation. I’m going to try and make it work directly with vanilla sortableJS
Vue降级到
3.2.30
问题解决了。vue.draggable.next
好像不维护了,真是难搞Hi guys, this is how I solved it, but need to change the source code, but there will be [Vue warn]: <TransitionGroup> children must be keyed. But don’t add key. For now, let’s do that. We need to change another way of thinking to solve this problem, such as not using vue version to develop
@FeckNeck open an issue there please
Not working for me either, I’m using Vue 3.2.33.
Draggable works fine without the transition on it, but I’m getting the same error as soon as I add
tag="transition-group"