anish2690 / vue-draggable-next

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

Unexpected mutation of "list" prop #56

Open AndreiSoroka opened 1 year ago

AndreiSoroka commented 1 year ago

Hi

<script setup>
  const list = ref([1,2,3])
</script>
<template>
  <Draggable :list="list"> <!-- <<< here -->
  ...

I expect: the list not will be change Why? Because :list="list" is a prop

If we want to change, should work two ways:

  1. either
    <Draggable v-model="list">
    <Draggable :model-value="list2" @update:model-value="list2 = $event">
  2. or
    <Draggable :list="list" @change="manualChangeList">

but not

  <Draggable :list="list">

https://vuejs.org/guide/components/props.html#one-way-data-flow I caught unexpected behavior, which gave rise to a couple of bugs in my code that I had to look for