Skip to content

Commit 405503b

Browse files
committed
more accessibility.
- row.template's expand row is a focusable `button`. It includes `aria-expanded`, `title` and `aria-label` also. - header.template: added missing`aria-label`s and `title`s for buttons. - table.template: added `aria-label` attribute for _select_ column. - added missing translations (note: demo page should be fixed as well)
1 parent d4014a0 commit 405503b

File tree

5 files changed

+34
-19
lines changed

5 files changed

+34
-19
lines changed

src/components/header.template.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ export const HEADER_TEMPLATE = `
33
<h4 class="title" [textContent]="dataTable.headerTitle"></h4>
44
<div class="button-panel">
55
<button type="button" class="btn btn-default btn-sm refresh-button"
6-
(click)="dataTable.reloadItems()">
6+
(click)="dataTable.reloadItems()"
7+
[attr.aria-label]="dataTable.translations.headerReload" [title]="dataTable.translations.headerReload">
78
<span class="glyphicon glyphicon-refresh"></span>
89
</button>
910
<button type="button" class="btn btn-default btn-sm column-selector-button" [class.active]="columnSelectorOpen"
10-
(click)="columnSelectorOpen = !columnSelectorOpen; $event.stopPropagation()" >
11+
(click)="columnSelectorOpen = !columnSelectorOpen; $event.stopPropagation()"
12+
[attr.aria-label]="dataTable.translations.headerColumnSelector" [title]="dataTable.translations.headerColumnSelector">
1113
<span class="glyphicon glyphicon-list"></span>
1214
</button>
1315
<div class="column-selector-wrapper" (click)="$event.stopPropagation()">
@@ -40,4 +42,4 @@ export const HEADER_TEMPLATE = `
4042
</div>
4143
</div>
4244
</div>
43-
`;
45+
`;

src/components/row.template.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ export const ROW_TEMPLATE = `
99
(dblclick)="dataTable.rowDoubleClicked(_this, $event)"
1010
(click)="dataTable.rowClicked(_this, $event)"
1111
>
12-
<td [hide]="!dataTable.expandColumnVisible" (click)="expanded = !expanded; $event.stopPropagation()" class="row-expand-button">
13-
<span class="glyphicon glyphicon-triangle-right" [hide]="expanded"></span>
14-
<span class="glyphicon glyphicon-triangle-bottom" [hide]="!expanded"></span>
12+
<td [hide]="!dataTable.expandColumnVisible">
13+
<div tabindex="0" role="button" (click)="expanded = !expanded; $event.stopPropagation()" class="row-expand-button"
14+
[attr.aria-expanded]="expanded" [title]="dataTable.translations.expandRow" [attr.aria-label]="dataTable.translations.expandRow">
15+
<span class="glyphicon" [ngClass]="{'glyphicon-triangle-right': !expanded, 'glyphicon-triangle-bottom': expanded}" aria-hidden="true"></span>
16+
</div>
1517
</td>
1618
<td [hide]="!dataTable.indexColumnVisible" class="index-column" [textContent]="displayIndex"></td>
1719
<td [hide]="!dataTable.selectColumnVisible" class="select-column">
@@ -28,4 +30,4 @@ export const ROW_TEMPLATE = `
2830
<div [ngTemplateOutlet]="dataTable.expandTemplate" [ngOutletContext]="{row: _this, item: item}"></div>
2931
</td>
3032
</tr>
31-
`;
33+
`;

src/components/table.template.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ export const TABLE_TEMPLATE = `
1111
<span [textContent]="indexColumnHeader"></span>
1212
</th>
1313
<th [hide]="!selectColumnVisible" class="select-column-header">
14-
<input [hide]="!multiSelect" type="checkbox" [(ngModel)]="selectAllCheckbox"/>
14+
<input [hide]="!multiSelect" type="checkbox" [(ngModel)]="selectAllCheckbox" [attr.aria-label]="translations.selectAllRows" />
1515
</th>
1616
<th *ngFor="let column of columns" #th [hide]="!column.visible"
17-
(click)="headerClicked(column, $event)" (keydown.enter)="headerClicked(column, $event)" (keydown.space)="headerClicked(column, $event)"
17+
(click)="headerClicked(column, $event)"
18+
(keydown.enter)="headerClicked(column, $event)" (keydown.space)="headerClicked(column, $event)"
1819
[class.sortable]="column.sortable" [class.resizable]="column.resizable"
1920
[ngClass]="column.styleClassObject" class="column-header" [style.width]="column.width | px"
2021
[attr.aria-sort]="column.sortable ? (column.property === sortBy ? (sortAsc ? 'ascending' : 'descending') : 'none') : null"
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
export interface DataTableTranslations {
2-
indexColumn: string;
3-
selectColumn: string;
4-
expandColumn: string;
5-
paginationLimit: string;
6-
paginationRange: string;
2+
headerReload: string,
3+
headerColumnSelector: string,
4+
indexColumn: string;
5+
selectColumn: string;
6+
selectRow: string;
7+
selectAllRows: string,
8+
expandColumn: string;
9+
expandRow: string;
10+
paginationLimit: string;
11+
paginationRange: string;
712
}
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import {DataTableTranslations} from'./data-table-translations.type'
22

33
export const defaultTranslations: DataTableTranslations = {
4-
indexColumn: 'index',
5-
selectColumn: 'select',
6-
expandColumn: 'expand',
7-
paginationLimit: 'Limit',
8-
paginationRange: 'Results'
4+
headerReload: 'reload',
5+
headerColumnSelector: 'column selector',
6+
indexColumn: 'index',
7+
selectColumn: 'select',
8+
selectRow: 'select',
9+
selectAllRows: 'select',
10+
expandColumn: 'expand',
11+
expandRow: 'expand',
12+
paginationLimit: 'Limit',
13+
paginationRange: 'Results'
914
};

0 commit comments

Comments
 (0)