Skip to content

Commit

Permalink
Fix primefaces#3443: Datatable: RowReorder fails in case of paginatio…
Browse files Browse the repository at this point in the history
…n on page other than first & last
  • Loading branch information
FlipWarthog committed Jan 7, 2023
1 parent ab88594 commit 7289eb8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/datatable/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 2 additions & 7 deletions components/utils/ObjectUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 7289eb8

Please sign in to comment.