Skip to content

Commit cfc22e9

Browse files
committed
fix: Update emitted when order has not changed
1 parent 09f9237 commit cfc22e9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Add option to only allow dragging when you click a handle element
88

9+
### Fixes
10+
11+
- fix: Update emitted when order has not changed
12+
913
## [v0.1.3] - 2022-12-07
1014

1115
### Changes

src/components/DraggableList.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,17 @@ const onDragEnd = () => {
202202
if (!window.draggingItem) return;
203203
const { itemIndex, itemListUuid, initialItemIndex, initialItemListUuid } =
204204
window.draggingItem;
205-
if (itemListUuid === initialItemListUuid)
205+
if (itemListUuid === initialItemListUuid) {
206+
if (initialItemIndex === itemIndex) return;
207+
206208
emit("update", {
207209
moved: {
208210
oldIndex: initialItemIndex,
209211
newIndex: itemIndex,
210212
updatedList: data.value
211213
}
212214
});
213-
else emit("update", {});
215+
} else emit("update", {});
214216
delete window.draggingItem;
215217
};
216218

0 commit comments

Comments
 (0)