Skip to content

Commit

Permalink
fix(stark-ui): multi-sorting on stark-table not working after sorting…
Browse files Browse the repository at this point in the history
… on single field

The issue was caused by the fact the ngClass multisorting was not changed.

ISSUES CLOSED: #3580
  • Loading branch information
mhenkens committed Mar 21, 2023
1 parent 74973fe commit 8705a4e
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -864,22 +864,23 @@ export class StarkTableComponent extends AbstractStarkUiComponent implements OnI
*/
public onReorderChange(column: StarkColumnSortChangedOutput): void {
if (column.sortable) {
this.resetSorting(column);
const sortedColumn = find(this.columns, { name: column.name });
if (sortedColumn) {
sortedColumn.sortPriority = 1;
switch (column.sortDirection) {
case "asc":
sortedColumn.sortDirection = "desc";
this.orderProperties = ["-" + sortedColumn.name];
break;
case "desc":
sortedColumn.sortDirection = "";
this.orderProperties = [];
break;
default:
sortedColumn.sortDirection = "asc";
this.orderProperties = [sortedColumn.name];
break;
}
}
this.isMultiSorting = false;
this.cdRef.detectChanges();
this.sortData();
}
}
Expand Down Expand Up @@ -919,6 +920,7 @@ export class StarkTableComponent extends AbstractStarkUiComponent implements OnI
}

this.orderProperties = newOrderProperties; // enforcing immutability :)
this.isMultiSorting = this.orderProperties.length > 1;
this.cdRef.detectChanges(); // needed due to ChangeDetectionStrategy.OnPush in order to refresh the columns

this.sortData();
Expand Down

0 comments on commit 8705a4e

Please sign in to comment.