Skip to content
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

fix: Avoid crashing when updated triggered before rendering #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SylvainBigonneau
Copy link

@SylvainBigonneau SylvainBigonneau commented May 6, 2021

This fixes an error that occurs when the list is first rendered empty: in some cases, upon adding the first item, it will not be rendered yet, therefore _ref.el will be null when it is checked and this crashes the lib.

@David-Desmaisons
Copy link
Member

@SylvainBigonneau Do you have an example of such problems?

@baptistejamin
Copy link

Hello @SylvainBigonneau and @David-Desmaisons !

We are currently moving the Crisp app to Vue 3, and it uses vue.draggable

We are facing the exact problem. In our case, the :list key is based on a computed properly, itself based on a VueX array.

In a such case, a race condition seems to occur in the draggable component, and this.componentStructure is undefined.

This PR seems to fix the problem

@baptistejamin
Copy link

Well, we just found the root of this problem :)

Since we are moving our app from Vue 2 to Vue 3, we are using the @vue/compat package.

We are now using this:

const draggableComponent = defineComponent({
  compatConfig: {
    RENDER_FUNCTION: false,
  },

By disabling the RENDER_FUNCTION we are forcing Vue to use the Vue 3 render mode.

@Androphin
Copy link

If I patch the parts of the code with that fix I still get an error with this.context is null when onDragStart is triggered.
It looks like it has to do with v-model used on the draggable component and the properties __draggable_context or underlying_vm aren't applied to the elements.

I figured out that it has to do with keys that aren't applied to the transitition-group if tag="transition-group" is set on the draggable component. SortableJS/Vue.Draggable#144

@rohini-mothe-maersk
Copy link

In which version of vuedraggable or vue-draggable-next we can get above fixes..i am also facing same issue?

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

Successfully merging this pull request may close these issues.

6 participants