Skip to content

Commit

Permalink
Fixed drag/drop input value auto update
Browse files Browse the repository at this point in the history
- Removed onEnd event in favor of onSort to get all updates from children
  • Loading branch information
asantibanez committed Mar 25, 2021
1 parent 0bdd90f commit 6b20e8b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions resources/views/components/scripts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,29 @@
wireOnSortOrderChange: null,
init() {
this.sortOrder = [].slice.call(this.$refs.root.children)
.map(child => child.dataset.sortKey)
.filter(sortKey => sortKey)
this.sortOrder = this.computeSortOrderFromChildren()
window.Sortable.create(this.$refs.root, {
handle: this.dragHandle,
animation: this.animation,
ghostClass: this.ghostClass,
group: this.group,
onEnd: evt => {
this.sortOrder = [].slice.call(evt.from.children)
.map(child => child.dataset.sortKey)
.filter(sortKey => sortKey)
onSort: evt => {
this.sortOrder = this.computeSortOrderFromChildren()
if (!this.wireComponent) {
return
}
this.wireComponent.call(this.wireOnSortOrderChange, this.sortOrder)
},
});
},
computeSortOrderFromChildren() {
return [].slice.call(this.$refs.root.children)
.map(child => child.dataset.sortKey)
.filter(sortKey => sortKey)
}
}
}
Expand Down

0 comments on commit 6b20e8b

Please sign in to comment.