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: NationalBankBelgium#3580
  • Loading branch information
mhenkens committed Mar 21, 2023
1 parent 74973fe commit b993659
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 45 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
64 changes: 32 additions & 32 deletions showcase/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@
"@angular/platform-server": "~7.2.2",
"@angular/router": "~7.2.2",
"@nationalbankbelgium/code-style": "^1.4.0",
"@nationalbankbelgium/stark-core": "file:../dist/packages-dist/stark-core/nationalbankbelgium-stark-core-10.2.4-2030164f.tgz",
"@nationalbankbelgium/stark-rbac": "file:../dist/packages-dist/stark-rbac/nationalbankbelgium-stark-rbac-10.2.4-2030164f.tgz",
"@nationalbankbelgium/stark-ui": "file:../dist/packages-dist/stark-ui/nationalbankbelgium-stark-ui-10.2.4-2030164f.tgz",
"@nationalbankbelgium/stark-core": "file:../dist/packages-dist/stark-core/nationalbankbelgium-stark-core-10.3.0-7cb334fc.tgz",
"@nationalbankbelgium/stark-rbac": "file:../dist/packages-dist/stark-rbac/nationalbankbelgium-stark-rbac-10.3.0-7cb334fc.tgz",
"@nationalbankbelgium/stark-ui": "file:../dist/packages-dist/stark-ui/nationalbankbelgium-stark-ui-10.3.0-7cb334fc.tgz",
"@uirouter/visualizer": "~7.2.1",
"angular-in-memory-web-api": "~0.8.0",
"basscss": "~8.1.0",
Expand All @@ -139,8 +139,8 @@
},
"devDependencies": {
"@compodoc/compodoc": "1.1.13",
"@nationalbankbelgium/stark-build": "file:../dist/packages-dist/stark-build/nationalbankbelgium-stark-build-10.2.4-2030164f.tgz",
"@nationalbankbelgium/stark-testing": "file:../dist/packages-dist/stark-testing/nationalbankbelgium-stark-testing-10.2.4-2030164f.tgz",
"@nationalbankbelgium/stark-build": "file:../dist/packages-dist/stark-build/nationalbankbelgium-stark-build-10.3.0-7cb334fc.tgz",
"@nationalbankbelgium/stark-testing": "file:../dist/packages-dist/stark-testing/nationalbankbelgium-stark-testing-10.3.0-7cb334fc.tgz",
"@types/core-js": "~2.5.4",
"@types/hammerjs": "~2.0.39",
"@types/node": "~10.17.54",
Expand Down
8 changes: 4 additions & 4 deletions starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@
"@angular/platform-server": "~7.2.2",
"@angular/router": "~7.2.2",
"@nationalbankbelgium/code-style": "^1.2.0",
"@nationalbankbelgium/stark-core": "latest",
"@nationalbankbelgium/stark-ui": "latest",
"@nationalbankbelgium/stark-core": "file:../dist/packages-dist/stark-core/nationalbankbelgium-stark-core-10.3.0-7cb334fc.tgz",
"@nationalbankbelgium/stark-ui": "file:../dist/packages-dist/stark-ui/nationalbankbelgium-stark-ui-10.3.0-7cb334fc.tgz",
"@uirouter/visualizer": "~7.2.1",
"core-js": "~3.8.0",
"eligrey-classlist-js-polyfill": "~1.2.20180112",
Expand All @@ -143,8 +143,8 @@
},
"devDependencies": {
"@compodoc/compodoc": "1.1.13",
"@nationalbankbelgium/stark-build": "latest",
"@nationalbankbelgium/stark-testing": "latest",
"@nationalbankbelgium/stark-build": "file:../dist/packages-dist/stark-build/nationalbankbelgium-stark-build-10.3.0-7cb334fc.tgz",
"@nationalbankbelgium/stark-testing": "file:../dist/packages-dist/stark-testing/nationalbankbelgium-stark-testing-10.3.0-7cb334fc.tgz",
"@types/core-js": "~2.5.0",
"@types/hammerjs": "~2.0.36",
"@types/node": "~10.17.13",
Expand Down

0 comments on commit b993659

Please sign in to comment.