Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(stark-ui): multi-sorting on stark-table not working after sorting on single field #3593

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -895,22 +895,22 @@ 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 All @@ -922,7 +922,7 @@ export class StarkTableComponent extends AbstractStarkUiComponent implements OnI
const dialogRef: MatDialogRef<StarkTableMultisortDialogComponent, StarkSortingRule[]> = this.dialogService.open<
StarkTableMultisortDialogComponent,
StarkTableMultisortDialogData
>(StarkTableMultisortDialogComponent, {
>(StarkTableMultisortDialogComponent, {
panelClass: "stark-table-dialog-multisort-panel-class", // the width is set via CSS using this class
data: { columns: this.columns.filter((column: StarkTableColumnComponent) => column.sortable) }
});
Expand Down Expand Up @@ -950,8 +950,8 @@ 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