Skip to content

Commit

Permalink
Fixed sorting bug for multi column sort
Browse files Browse the repository at this point in the history
There was a bug in multi column sort where the orders and sort fields  would be reversed on table redraws without the user changing the sort info. This was because array.reverse() was used which changes the underlying array. Applying slice().reverse() first makes a copy of the original array and then returns the reverse of it, leaving the original arrays in a correct state.
  • Loading branch information
victorkirov committed Jan 30, 2017
1 parent 3c41019 commit b2ff491
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/store/TableDataStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export class TableDataStore {
if (order.length !== sortField.length) {
throw new Error('The length of sort fields and orders should be equivalent');
}
order = order.reverse();
this.sortList = sortField.reverse().map((field, i) => {
order = order.slice().reverse();
this.sortList = sortField.slice().reverse().map((field, i) => {
return {
order: order[i],
sortField: field
Expand Down

0 comments on commit b2ff491

Please sign in to comment.