From b910dc526529f9e87d1e458884fef7f9ac69de74 Mon Sep 17 00:00:00 2001 From: nclemeur_daesim Date: Tue, 1 Mar 2022 12:11:44 +1000 Subject: [PATCH] Fixing #2225 --- src/components/datatable/DataTable.vue | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/components/datatable/DataTable.vue b/src/components/datatable/DataTable.vue index 3ed083ac2c..20cf499712 100755 --- a/src/components/datatable/DataTable.vue +++ b/src/components/datatable/DataTable.vue @@ -1252,21 +1252,16 @@ export default { if (this.draggedColumn) { let dragIndex = DomHandler.index(this.draggedColumn); let dropIndex = DomHandler.index(this.findParentHeader(event.target)); - let allowDrop = (dragIndex !== dropIndex); - if (allowDrop && ((dropIndex - dragIndex === 1 && this.dropPosition === -1) || (dragIndex - dropIndex === 1 && this.dropPosition === 1))) { - allowDrop = false; - } + let allowDrop = dragIndex !== dropIndex; if (allowDrop) { - ObjectUtils.reorderArray(this.columns, dragIndex, dropIndex); - this.updateReorderableColumns(); - - this.$emit('column-reorder', { - originalEvent: event, - dragIndex: dragIndex, - dropIndex: dropIndex - }); + if (this.dropPosition === 1 && dragIndex > dropIndex) { + dropIndex++; + } else if (this.dropPosition === -1 && dragIndex < dropIndex) { + dropIndex--; + } } + allowDrop = dragIndex !== dropIndex; this.$refs.reorderIndicatorUp.style.display = 'none'; this.$refs.reorderIndicatorDown.style.display = 'none';