[ACS-10241]: Personal files: Column sorting state and role not communicated by buttons (parially reverted to align with hxp) (#11598)

* [ACS-10241]: partially reverted changes

* [ACS-10241]: restored aria-label
This commit is contained in:
Anton Ramanovich
2026-01-30 12:54:16 +01:00
committed by GitHub
parent 4987bbadef
commit 3bba02264a
3 changed files with 18 additions and 17 deletions
@@ -54,7 +54,8 @@
'adf-datatable__header--sorted-desc': isColumnSorted(col, 'desc')}" 'adf-datatable__header--sorted-desc': isColumnSorted(col, 'desc')}"
[ngStyle]="(col.width) && !lastColumn && {'flex': getFlexValue(col)}" [ngStyle]="(col.width) && !lastColumn && {'flex': getFlexValue(col)}"
role="columnheader" role="columnheader"
[attr.aria-sort]="col.sortable ? getAriaSort(col) : null" [attr.aria-label]="col.srTitle ? (col.srTitle | translate) : (col.title | translate) + (col.subtitle ? ' ' + (col.subtitle | translate) : '')"
[attr.aria-sort]="col.sortable ? (getAriaSort(col) | translate) : null"
cdkDrag cdkDrag
cdkDragLockAxis="x" cdkDragLockAxis="x"
(cdkDragStarted)="isDraggingHeaderColumn = true" (cdkDragStarted)="isDraggingHeaderColumn = true"
@@ -74,7 +75,7 @@
[attr.aria-description]=" [attr.aria-description]="
isColumnSortActive(col) ? (getSortLiveAnnouncement(col) | translate: { string: col.title | translate }) : null isColumnSortActive(col) ? (getSortLiveAnnouncement(col) | translate: { string: col.title | translate }) : null
" "
[attr.aria-label]=" [attr.aria-label]="
col.srTitle col.srTitle
? (col.srTitle | translate) ? (col.srTitle | translate)
: ('ADF-DATATABLE.ACCESSIBILITY.SORT_DEFAULT' | translate) + : ('ADF-DATATABLE.ACCESSIBILITY.SORT_DEFAULT' | translate) +
@@ -96,10 +97,6 @@
!isDraggingHeaderColumn && !isDraggingHeaderColumn &&
!isResizing && col.sortable}" !isResizing && col.sortable}"
> >
<span *ngIf="col.title && col.sortable" class="adf-sr-only" aria-live="assertive" aria-atomic="true">
{{ getSortLiveAnnouncement(col) | translate: { string: col.title | translate } }}
</span>
<ng-container *ngIf="!col.header"> <ng-container *ngIf="!col.header">
<span <span
*ngIf="col.title" *ngIf="col.title"
@@ -117,6 +114,10 @@
({{col.subtitle | translate}}) ({{col.subtitle | translate}})
</span> </span>
<span *ngIf="col.title && col.sortable && isDraggingHeaderColumn" class="adf-sr-only" aria-live="polite">
{{ getSortLiveAnnouncement(col) | translate: { string: col.title | translate } }}
</span>
<span *ngIf="!col.title && !col.sortable && !headerFilterTemplate" [attr.title]="'ADF-DATATABLE.ACCESSIBILITY.EMPTY_HEADER' | translate"></span> <span *ngIf="!col.title && !col.sortable && !headerFilterTemplate" [attr.title]="'ADF-DATATABLE.ACCESSIBILITY.EMPTY_HEADER' | translate"></span>
</ng-container> </ng-container>
@@ -1673,25 +1673,25 @@ describe('Accessibility', () => {
column = new ObjectDataColumn({ key: 'key' }); column = new ObjectDataColumn({ key: 'key' });
}); });
it('should return correct key without translation when no sort is applied', () => { it('should return correct translation key when no sort is applied', () => {
spyOn(dataTable, 'isColumnSortActive').and.returnValue(false); spyOn(dataTable, 'isColumnSortActive').and.returnValue(false);
expect(dataTable.getAriaSort(column)).toBe('none'); expect(dataTable.getAriaSort(column)).toBe('ADF-DATATABLE.ACCESSIBILITY.SORT_NONE');
}); });
it('should return key without translation when column sort is ascending', () => { it('should return translation key when column sort is ascending', () => {
const isColumnSortedAsc = true; const isColumnSortedAsc = true;
spyOn(dataTable, 'isColumnSortActive').and.returnValue(true); spyOn(dataTable, 'isColumnSortActive').and.returnValue(true);
spyOn(dataTable, 'isColumnSorted').and.returnValue(isColumnSortedAsc); spyOn(dataTable, 'isColumnSorted').and.returnValue(isColumnSortedAsc);
expect(dataTable.getAriaSort(column)).toBe('ascending'); expect(dataTable.getAriaSort(column)).toBe('ADF-DATATABLE.ACCESSIBILITY.SORT_ASCENDING');
}); });
it('should return key without translation when column sort is descending', () => { it('should return translation key when column sort is descending', () => {
const isColumnSortedAsc = false; const isColumnSortedAsc = false;
spyOn(dataTable, 'isColumnSortActive').and.returnValue(true); spyOn(dataTable, 'isColumnSortActive').and.returnValue(true);
spyOn(dataTable, 'isColumnSorted').and.returnValue(isColumnSortedAsc); spyOn(dataTable, 'isColumnSorted').and.returnValue(isColumnSortedAsc);
expect(dataTable.getAriaSort(column)).toBe('descending'); expect(dataTable.getAriaSort(column)).toBe('ADF-DATATABLE.ACCESSIBILITY.SORT_DESCENDING');
}); });
}); });
@@ -1757,7 +1757,7 @@ describe('Accessibility', () => {
}); });
}); });
it('should allow header cell focus when cell is sortable', () => { it('should remove header cell focus when cell is sortable', () => {
setupAndCheckHeaderColumns(true, headerCellSelector, (element) => { setupAndCheckHeaderColumns(true, headerCellSelector, (element) => {
expect(element?.nativeElement.getAttribute('tabindex')).toBeNull(); expect(element?.nativeElement.getAttribute('tabindex')).toBeNull();
}); });
@@ -1775,9 +1775,9 @@ describe('Accessibility', () => {
}); });
}); });
it('should set tabindex equal to 0 on header cell sortable wrapper when cell is sortable', () => { it('should set tabindex equal to null on header cell sortable wrapper when cell is sortable', () => {
setupAndCheckHeaderColumns(true, headerCellContentSelector, (element) => { setupAndCheckHeaderColumns(true, headerCellContentSelector, (element) => {
expect(element?.nativeElement.getAttribute('tabindex')).toBe('0'); expect(element?.nativeElement.getAttribute('tabindex')).toEqual('0');
}); });
}); });
@@ -1032,10 +1032,10 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
getAriaSort(column: DataColumn): string { getAriaSort(column: DataColumn): string {
if (!this.isColumnSortActive(column)) { if (!this.isColumnSortActive(column)) {
return 'none'; return 'ADF-DATATABLE.ACCESSIBILITY.SORT_NONE';
} }
return this.isColumnSorted(column, 'asc') ? 'ascending' : 'descending'; return this.isColumnSorted(column, 'asc') ? 'ADF-DATATABLE.ACCESSIBILITY.SORT_ASCENDING' : 'ADF-DATATABLE.ACCESSIBILITY.SORT_DESCENDING';
} }
getSortLiveAnnouncement(column: DataColumn): string { getSortLiveAnnouncement(column: DataColumn): string {