Alfred-Skyblue / vue-draggable-plus

Universal Drag-and-Drop Component Supporting both Vue 3 and Vue 2
https://vue-draggable-plus.pages.dev/en/
MIT License
3.1k stars 130 forks source link

Bug When moving last element to then adding another one #206

Closed Ratinax closed 2 hours ago

Ratinax commented 2 hours ago

Hello I have found a bug that displays the elements in the wrong order: Screencast from 2024-10-25 08-20-24.webm

To reproduce:

For more detail it occures when:

For more detail here's my code:

<!-- VueDraggable 1 -->
<VueDraggable
          group="items"
          :animation="150"
          v-model="itemList"
          >

        <v-card class="mr-2" :key="index" v-for="(element, index) in itemList" variant="outlined">
          <div>
            <span>{{index}} {{ element.name }}</span>
          </div>
        </v-card>
      </VueDraggable>

<!-- VueDraggable 2 -->
<VueDraggable
            v-model="items"
            :group="{ name: 'items', pull: 'clone', put: false }"
            :sort="false"
        >
          <v-card class="ma-1 pa-2 list-group-item" v-for="(criteria, index) in criteriaList" :key="criteria.id"
                  :color="criteria.color" variant="outlined">
            {{ criteria.name[0] }} {{ index }}
          </v-card>
        </VueDraggable>
<script setup lang="ts">
const itemList: Ref = ref([]);

const items = ref([
  {"id": 1, "name": "item1"},
  {"id": 2, "name": "item2"},
  {"id": 3, "name": "item3"},
]);
</script>
Ratinax commented 2 hours ago

Sorry I didn't took a look at the FAQ section on the doc, my bad