anish2690 / vue-draggable-next

Vue 3 drag-and-drop component
https://vue-draggable-next.vercel.app
MIT License
508 stars 45 forks source link

Both v-model and :list are modified on drag&drop #57

Closed LukMas closed 10 months ago

LukMas commented 1 year ago

Hi! I don't know how to solve the problem I have with Drag&Drop. Up to now I've had two buttons move up and move down to change the position of the elements of the list. Each change was requesting an update on the server and with a success the objects were moved (hence, every move required an ok from the server, then the list was updated). Being the list stored into the state part of a Pinia store, once they updated Vue proceeded to redraw the UI. But, if I use the Drag&Drop, I can't have the same behaviour. I manage the onEnd event, so I proceed with the call on the server once the user has stopped to drag the object. I've supposed that if use the v-model, as written on the documentation, no changes are performed on the model as long I return a false in the function. But it's not the case. With both v-model and :list the content is changed. That means that I can't use the same function used in moveUp/moveDown, because otherwise I perform another change. The only way to obtain the original status is to add whole new set of functions that are used only for Drag&Drop.

Is this normal? I mean, is normal that both v-model and :list are not immutable?

anish2690 commented 10 months ago

@LukMas v-model is by-directional but list is not