vue-moveable icon indicating copy to clipboard operation
vue-moveable copied to clipboard

Unable to use groups after initialization

Open dartanian300 opened this issue 5 years ago • 3 comments

Based on the Moveable documentation (found here: https://github.com/daybrush/moveable/blob/0.13.4/handbook/handbook.md#toc-group), you can create a group of moveable elements by passing an array to the target property. However, doing so in vue-moveable after initialization throws the following error:

Uncaught (in promise) TypeError: Cannot read property 'addEventListener' of undefined

I've confirmed that this occurs no matter the type of elements. It's present with both div and svg. Additionally, if the array has only a single element in it, this error does not occur.

Demo: https://codesandbox.io/s/vue-moveable-group-problem-9r6sf?fontsize=14&hidenavigation=1&theme=dark

Vue-Moveable version: 1.4.0

dartanian300 avatar Mar 01 '20 22:03 dartanian300

Hi @dartanian300 👋 Thanks for your issue. Groups are not supported right now. Some work was done in v1.6.0 to make it work properly but it still needs testing

probil avatar Mar 13 '20 07:03 probil

Any updates on when groups will be supported? I am having the same issue unfortunately. Digging into this package and moveable package to figure out why it's doing this. While debugging, it turns out that nextTarget is null because dragTarget and areaElement are both null -- this leads to the Uncaught (in promise) TypeError: Cannot read property 'addEventListener' of undefined error. This is in the updateEvent function for MoveableGroup in the Moveable package.

Screenshot at 2021-04-19 10-34-46

bkowzx avatar Apr 19 '21 17:04 bkowzx

Finally figured out what the problem was. Boolean props have a default value of False. This was screwing everything up. I replaced every Boolean prop value from Boolean to {type: Boolean, required: false, default: undefined } in Moveable.vue component, and it worked! So I believe that's the fix that needs to be made in this package for groups to work.

bkowzx avatar Apr 19 '21 18:04 bkowzx