From 3fc8630f4854251fa09207ce31fc1c510b1bca0c Mon Sep 17 00:00:00 2001 From: Mert Sincan Date: Tue, 17 Dec 2024 14:29:15 +0000 Subject: [PATCH] Fixed #17090 - Table: aria-sort not updated when sorting multiple columns --- packages/primeng/src/table/table.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/primeng/src/table/table.ts b/packages/primeng/src/table/table.ts index bed2fed6dbd..a88b3c0e2a6 100644 --- a/packages/primeng/src/table/table.ts +++ b/packages/primeng/src/table/table.ts @@ -3627,8 +3627,20 @@ export class SortableColumn implements OnInit, OnDestroy { } updateSortState() { - this.sorted = this.dt.isSorted(this.field) as boolean; - this.sortOrder = this.sorted ? (this.dt.sortOrder === 1 ? 'ascending' : 'descending') : 'none'; + let sorted = false; + let sortOrder = 0; + + if (this.dt.sortMode === 'single') { + sorted = this.dt.isSorted(this.field) as boolean; + sortOrder = this.dt.sortOrder; + } else if (this.dt.sortMode === 'multiple') { + const sortMeta = this.dt.getSortMeta(this.field); + sorted = !!sortMeta; + sortOrder = sortMeta ? sortMeta.order : 0; + } + + this.sorted = sorted; + this.sortOrder = sorted ? (sortOrder === 1 ? 'ascending' : 'descending') : 'none'; } @HostListener('click', ['$event'])