mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
accessibility enhancements for datatable (#2266)
This commit is contained in:
committed by
Mario Romano
parent
287630d40f
commit
9625484977
@@ -18,7 +18,11 @@
|
|||||||
[attr.data-automation-id]="'auto_id_' + col.key"
|
[attr.data-automation-id]="'auto_id_' + col.key"
|
||||||
[class.adf-data-table__header--sorted-asc]="isColumnSorted(col, 'asc')"
|
[class.adf-data-table__header--sorted-asc]="isColumnSorted(col, 'asc')"
|
||||||
[class.adf-data-table__header--sorted-desc]="isColumnSorted(col, 'desc')"
|
[class.adf-data-table__header--sorted-desc]="isColumnSorted(col, 'desc')"
|
||||||
(click)="onColumnHeaderClick(col)">
|
(click)="onColumnHeaderClick(col)"
|
||||||
|
(keyup.enter)="onColumnHeaderClick(col)"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
title="{{ col.title }}">
|
||||||
<span *ngIf="col.srTitle" class="sr-only">{{col.srTitle}}</span>
|
<span *ngIf="col.srTitle" class="sr-only">{{col.srTitle}}</span>
|
||||||
<span *ngIf="col.title">{{ col.title | translate}}</span>
|
<span *ngIf="col.title">{{ col.title | translate}}</span>
|
||||||
</th>
|
</th>
|
||||||
@@ -31,11 +35,14 @@
|
|||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<ng-container *ngIf="!loading">
|
<ng-container *ngIf="!loading">
|
||||||
<tr *ngFor="let row of data.getRows(); let idx = index" tabindex="0"
|
<tr *ngFor="let row of data.getRows(); let idx = index"
|
||||||
|
tabindex="0"
|
||||||
|
role="button"
|
||||||
[class.is-selected]="row.isSelected"
|
[class.is-selected]="row.isSelected"
|
||||||
[adf-upload]="allowDropFiles && rowAllowsDrop(row)" [adf-upload-data]="row"
|
[adf-upload]="allowDropFiles && rowAllowsDrop(row)" [adf-upload-data]="row"
|
||||||
[ngStyle]="rowStyle"
|
[ngStyle]="rowStyle"
|
||||||
[ngClass]="getRowStyle(row)">
|
[ngClass]="getRowStyle(row)"
|
||||||
|
(keyup.enter)="onKeyboardNavigate(row, $event)">
|
||||||
|
|
||||||
<!-- Actions (left) -->
|
<!-- Actions (left) -->
|
||||||
<td *ngIf="actions && actionsPosition === 'left'">
|
<td *ngIf="actions && actionsPosition === 'left'">
|
||||||
@@ -62,6 +69,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td *ngFor="let col of data.getColumns()"
|
<td *ngFor="let col of data.getColumns()"
|
||||||
class="adf-data-table-cell adf-data-table-cell--{{col.type || 'text'}} {{col.cssClass}}"
|
class="adf-data-table-cell adf-data-table-cell--{{col.type || 'text'}} {{col.cssClass}}"
|
||||||
|
tabindex="0"
|
||||||
(click)="onRowClick(row, $event)"
|
(click)="onRowClick(row, $event)"
|
||||||
[context-menu]="getContextMenuActions(row, col)"
|
[context-menu]="getContextMenuActions(row, col)"
|
||||||
[context-menu-enabled]="contextMenu">
|
[context-menu-enabled]="contextMenu">
|
||||||
|
@@ -82,6 +82,13 @@
|
|||||||
&:last-of-type {
|
&:last-of-type {
|
||||||
padding-right: 24px;
|
padding-right: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline-offset: -1px;
|
||||||
|
outline-width: 1px;
|
||||||
|
outline-color: rgb(68, 138, 255);
|
||||||
|
outline-style: solid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
|
@@ -280,6 +280,21 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck
|
|||||||
this.clickObserver.next(dataRowEvent);
|
this.clickObserver.next(dataRowEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onKeyboardNavigate(row: DataRow, e: KeyboardEvent) {
|
||||||
|
if (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
const event = new DataRowEvent(row, e, this);
|
||||||
|
|
||||||
|
this.rowDblClick.emit(event);
|
||||||
|
this.elementRef.nativeElement.dispatchEvent(
|
||||||
|
new CustomEvent('row-dblclick', {
|
||||||
|
detail: event,
|
||||||
|
bubbles: true
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
onColumnHeaderClick(column: DataColumn) {
|
onColumnHeaderClick(column: DataColumn) {
|
||||||
if (column && column.sortable) {
|
if (column && column.sortable) {
|
||||||
let current = this.data.getSorting();
|
let current = this.data.getSorting();
|
||||||
|
Reference in New Issue
Block a user