From cfc22e94d87a05492a255dd177d65c6968cd8590 Mon Sep 17 00:00:00 2001 From: Owen Diffey Date: Sat, 15 Jun 2024 17:43:46 +0100 Subject: [PATCH] fix: Update emitted when order has not changed --- CHANGELOG.md | 4 ++++ src/components/DraggableList.vue | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f472def..8ee639b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - Add option to only allow dragging when you click a handle element +### Fixes + +- fix: Update emitted when order has not changed + ## [v0.1.3] - 2022-12-07 ### Changes diff --git a/src/components/DraggableList.vue b/src/components/DraggableList.vue index 07b7c25..eee5375 100644 --- a/src/components/DraggableList.vue +++ b/src/components/DraggableList.vue @@ -202,7 +202,9 @@ const onDragEnd = () => { if (!window.draggingItem) return; const { itemIndex, itemListUuid, initialItemIndex, initialItemListUuid } = window.draggingItem; - if (itemListUuid === initialItemListUuid) + if (itemListUuid === initialItemListUuid) { + if (initialItemIndex === itemIndex) return; + emit("update", { moved: { oldIndex: initialItemIndex, @@ -210,7 +212,7 @@ const onDragEnd = () => { updatedList: data.value } }); - else emit("update", {}); + } else emit("update", {}); delete window.draggingItem; };