Skip to content

Commit

Permalink
fix: Update emitted when order has not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
odiffey committed Jun 15, 2024
1 parent 09f9237 commit cfc22e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/components/DraggableList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,17 @@ 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,
newIndex: itemIndex,
updatedList: data.value
}
});
else emit("update", {});
} else emit("update", {});
delete window.draggingItem;
};
Expand Down

0 comments on commit cfc22e9

Please sign in to comment.