From 7289eb83231e62f407e0726ff28bc3b68c7cf94a Mon Sep 17 00:00:00 2001 From: FlipWarthog Date: Fri, 6 Jan 2023 19:22:05 -0500 Subject: [PATCH] Fix #3443: Datatable: RowReorder fails in case of pagination on page other than first & last --- components/datatable/DataTable.vue | 2 +- components/utils/ObjectUtils.js | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/components/datatable/DataTable.vue b/components/datatable/DataTable.vue index bf34932d95..dba83fd8de 100755 --- a/components/datatable/DataTable.vue +++ b/components/datatable/DataTable.vue @@ -1685,7 +1685,7 @@ export default { let dropIndex = this.draggedRowIndex > this.droppedRowIndex ? this.droppedRowIndex : this.droppedRowIndex === 0 ? 0 : this.droppedRowIndex - 1; let processedData = [...this.processedData]; - ObjectUtils.reorderArray(processedData, this.draggedRowIndex, dropIndex); + ObjectUtils.reorderArray(processedData, this.draggedRowIndex + this.d_first, dropIndex + this.d_first); this.$emit('row-reorder', { originalEvent: event, diff --git a/components/utils/ObjectUtils.js b/components/utils/ObjectUtils.js index 8183b4ca50..e637e66326 100755 --- a/components/utils/ObjectUtils.js +++ b/components/utils/ObjectUtils.js @@ -106,15 +106,10 @@ export default { }, reorderArray(value, from, to) { - let target; - if (value && from !== to) { if (to >= value.length) { - target = to - value.length; - - while (target-- + 1) { - value.push(undefined); - } + to %= value.length; + from %= value.length; } value.splice(to, 0, value.splice(from, 1)[0]);