diff --git a/src/DragGrid.vue b/src/DragGrid.vue index 56b27c66db1cee5e5ed912cac18357f329550904..8922a0d3bb81f8c87e88a01d3d539f28e4f914f7 100644 --- a/src/DragGrid.vue +++ b/src/DragGrid.vue @@ -199,6 +199,9 @@ export default { if (!newPositionValid) return; + element.x = coords.x; + element.y = coords.y; + try { let valueCopy = structuredClone(this.value); @@ -207,7 +210,12 @@ export default { }); if (index >= 0) valueCopy.splice(index, 1); - valueCopy.push(element); + let elementCopy = structuredClone(element); + + elementCopy.context = undefined; + elementCopy.originGridId = undefined; + + valueCopy.push(elementCopy); this.$emit("input", valueCopy); } catch (e) { if (e.code === DOMException.DATA_CLONE_ERR) { @@ -220,9 +228,8 @@ export default { } } - element.x = coords.x; - element.y = coords.y; element.gridId = this.gridId; + this.$emit("itemChanged", element); }, getCoords(x, y) {