Fix #3443: Datatable: RowReorder fails in case of pagination on page other than first & last

pull/3502/head
FlipWarthog 2023-01-06 19:22:05 -05:00
parent ab885948c5
commit 7289eb8323
2 changed files with 3 additions and 8 deletions

View File

@ -1685,7 +1685,7 @@ export default {
let dropIndex = this.draggedRowIndex > this.droppedRowIndex ? this.droppedRowIndex : this.droppedRowIndex === 0 ? 0 : this.droppedRowIndex - 1; let dropIndex = this.draggedRowIndex > this.droppedRowIndex ? this.droppedRowIndex : this.droppedRowIndex === 0 ? 0 : this.droppedRowIndex - 1;
let processedData = [...this.processedData]; 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', { this.$emit('row-reorder', {
originalEvent: event, originalEvent: event,

View File

@ -106,15 +106,10 @@ export default {
}, },
reorderArray(value, from, to) { reorderArray(value, from, to) {
let target;
if (value && from !== to) { if (value && from !== to) {
if (to >= value.length) { if (to >= value.length) {
target = to - value.length; to %= value.length;
from %= value.length;
while (target-- + 1) {
value.push(undefined);
}
} }
value.splice(to, 0, value.splice(from, 1)[0]); value.splice(to, 0, value.splice(from, 1)[0]);