From e14e489d2d1da0e246672974316cf2120ebb5e73 Mon Sep 17 00:00:00 2001 From: DominikIwanek <141320833+DominikIwanek@users.noreply.github.com> Date: Tue, 12 Sep 2023 16:07:16 +0200 Subject: [PATCH] [ACA-4313] - Sort order doesn't work correctly (#8892) [ACA-4313] - Sort order doesn't work correctly --- .../document-list/components/document-list.component.ts | 1 + .../datatable/components/datatable/datatable.component.ts | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.ts b/lib/content-services/src/lib/document-list/components/document-list.component.ts index 641de672c0..881265aeb5 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.ts @@ -742,6 +742,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte onSortingChanged(event: CustomEvent) { this.orderBy = this.buildOrderByArray(event.detail.sortingKey, event.detail.direction); + this.sorting = [event.detail.sortingKey, event.detail.direction]; this.sortingSubject.next([this.additionalSorting, event.detail]); if (this.sortingMode === 'server') { diff --git a/lib/core/src/lib/datatable/components/datatable/datatable.component.ts b/lib/core/src/lib/datatable/components/datatable/datatable.component.ts index 70a75b6c95..bf1da0f12b 100644 --- a/lib/core/src/lib/datatable/components/datatable/datatable.component.ts +++ b/lib/core/src/lib/datatable/components/datatable/datatable.component.ts @@ -742,7 +742,7 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges, isColumnSorted(col: DataColumn, direction: string): boolean { if (col && direction) { const sorting = this.data.getSorting(); - return sorting && sorting.key === col.key && sorting.direction.toLocaleLowerCase() === direction; + return this.isSortingEqual(col, direction, sorting); } return false; } @@ -1018,6 +1018,12 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges, this.columnsWidthChanged.emit(allColumns); } + + private isSortingEqual(col: DataColumn, direction: string, sorting: DataSorting): boolean { + return sorting && + (sorting.key === col.key || sorting.key === col.sortingKey) && + sorting.direction?.toLocaleLowerCase() === direction; + }; } export interface DataTableDropEvent {