From 9acd7a7c7f7c5a7dd9bc29632204484230e698ed Mon Sep 17 00:00:00 2001 From: Viktor Slavov Date: Thu, 14 Feb 2019 22:49:24 +0200 Subject: [PATCH] docs(table): add aria-label to checkboxes in selection example (#15158) Fixes #15021 --- .../table-selection/table-selection-example.html | 6 ++++-- .../table-selection/table-selection-example.ts | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/material-examples/table-selection/table-selection-example.html b/src/material-examples/table-selection/table-selection-example.html index a22d56266de..9bf76f15a32 100644 --- a/src/material-examples/table-selection/table-selection-example.html +++ b/src/material-examples/table-selection/table-selection-example.html @@ -5,13 +5,15 @@ + [indeterminate]="selection.hasValue() && !isAllSelected()" + [aria-label]="checkboxLabel()"> + [checked]="selection.isSelected(row)" + [aria-label]="checkboxLabel(row)"> diff --git a/src/material-examples/table-selection/table-selection-example.ts b/src/material-examples/table-selection/table-selection-example.ts index 15336737658..2b760109fa2 100644 --- a/src/material-examples/table-selection/table-selection-example.ts +++ b/src/material-examples/table-selection/table-selection-example.ts @@ -48,4 +48,12 @@ export class TableSelectionExample { this.selection.clear() : this.dataSource.data.forEach(row => this.selection.select(row)); } + + /** The label for the checkbox on the passed row */ + checkboxLabel(row?: PeriodicElement): string { + if (!row) { + return `${this.isAllSelected() ? 'select' : 'deselect'} all`; + } + return `${this.selection.isSelected(row) ? 'deselect' : 'select'} row ${row.position + 1}`; + } }