Skip to content

Commit 6d951b2

Browse files
adamascgmportuga
authored andcommitted
feat(cellnav): output aria text for cells that come from selection feature
1 parent 209fc1d commit 6d951b2

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

misc/tutorial/210_selection.ngdoc

+24-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ auto-selects the first row once the data is loaded.
5757

5858
<example module="app">
5959
<file name="app.js">
60-
var app = angular.module('app', ['ngTouch', 'ui.grid', 'ui.grid.selection']);
60+
var app = angular.module('app', ['ngTouch', 'ui.grid', 'ui.grid.selection', 'ui.grid.cellNav', 'ngAria']);
6161

6262
app.controller('MainCtrl', ['$scope', '$http', '$log', '$timeout', 'uiGridConstants', function ($scope, $http, $log, $timeout, uiGridConstants) {
6363
$scope.gridOptions = {
@@ -192,7 +192,7 @@ auto-selects the first row once the data is loaded.
192192
<button type="button" class="btn btn-success" ng-click="toggleFullRowSelection()">Toggle full row selection</button>
193193
<br/>
194194

195-
<div ui-grid="gridOptions" ui-grid-selection class="grid"></div>
195+
<div id="grid1Selection" ui-grid="gridOptions" ui-grid-selection ui-grid-cellnav class="grid"></div>
196196
</div>
197197
<div ng-controller="SecondCtrl">
198198
Single selection grid without rowHeader, and allowing rowSelection to be toggled on and off dynamically:
@@ -207,4 +207,26 @@ auto-selects the first row once the data is loaded.
207207
height: 400px;
208208
}
209209
</file>
210+
<file name="scenario.js">
211+
var gridTestUtils = require('../../test/e2e/gridTestUtils.spec.js');
212+
var GridObjectTest = require('../../test/e2e/gridObjectTestUtils.spec.js');
213+
var grid1Selection = new GridObjectTest('grid1Selection');
214+
215+
describe('210 tutorial', function() {
216+
xit('should output aria text for cells that come from selection feature', function () {
217+
pending('For unknown reasons causes next test suite to fail. It looks as if the page for the next test was not loaded before selectors/expects fire.')
218+
var focuser = element(by.css('.ui-grid-focuser'));
219+
grid1Selection.selectRow(1).then(function () {
220+
return gridTestUtils.click(focuser);
221+
})
222+
.then(function () {
223+
expect(element(by.css('.ui-grid-a11y-ariascreenreader-speakable.ui-grid-offscreen')).getInnerHtml()).toEqual('Row selected ');
224+
return focuser.sendKeys(protractor.Key.ARROW_DOWN);
225+
})
226+
.then(function () {
227+
expect(element(by.css('.ui-grid-a11y-ariascreenreader-speakable.ui-grid-offscreen')).getInnerHtml()).toEqual('Row not selected ');
228+
})
229+
});
230+
});
231+
</file>
210232
</example>

src/features/cellnav/js/cellnav.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@
629629
</file>
630630
</example>
631631
*/
632-
module.directive('uiGridCellnav', ['gridUtil', 'uiGridCellNavService', 'uiGridCellNavConstants', 'uiGridConstants', 'GridRowColumn', '$timeout', '$compile',
633-
function (gridUtil, uiGridCellNavService, uiGridCellNavConstants, uiGridConstants, GridRowColumn, $timeout, $compile) {
632+
module.directive('uiGridCellnav', ['gridUtil', 'uiGridCellNavService', 'uiGridCellNavConstants', 'uiGridConstants', 'GridRowColumn', '$timeout', '$compile', 'i18nService',
633+
function (gridUtil, uiGridCellNavService, uiGridCellNavConstants, uiGridConstants, GridRowColumn, $timeout, $compile, i18nService) {
634634
return {
635635
replace: true,
636636
priority: -150,
@@ -833,10 +833,22 @@
833833
}
834834
}
835835

836+
function getCellDisplayValue(currentRowColumn) {
837+
if (currentRowColumn.col.field === 'selectionRowHeaderCol') {
838+
// This is the case when the 'selection' feature is used in the grid and the user has moved
839+
// to or inside of the left grid container which holds the checkboxes for selecting rows.
840+
// This is necessary for Accessibility. Without this a screen reader cannot determine if the row
841+
// is or is not currently selected.
842+
return currentRowColumn.row.isSelected ? i18nService.getSafeText('search.aria.selected') : i18nService.getSafeText('search.aria.notSelected');
843+
} else {
844+
return grid.getCellDisplayValue(currentRowColumn.row, currentSelection[i].col);
845+
}
846+
}
847+
836848
var values = [];
837849
var currentSelection = grid.api.cellNav.getCurrentSelection();
838850
for (var i = 0; i < currentSelection.length; i++) {
839-
values.push(grid.getCellDisplayValue(currentSelection[i].row, currentSelection[i].col));
851+
values.push(getCellDisplayValue(currentSelection[i]));
840852
}
841853
var cellText = values.toString();
842854
setNotifyText(cellText);

src/js/i18n/de.js

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
description: 'Ziehen Sie eine Spaltenüberschrift hierhin, um nach dieser Spalte zu gruppieren.'
2222
},
2323
search: {
24+
aria: {
25+
selected: 'Zeile markiert',
26+
notSelected: 'Zeile nicht markiert'
27+
},
2428
placeholder: 'Suche...',
2529
showingItems: 'Zeige Einträge:',
2630
selectedItems: 'Ausgewählte Einträge:',

src/js/i18n/en.js

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
description: 'Drag a column header here and drop it to group by that column.'
2222
},
2323
search: {
24+
aria: {
25+
selected: 'Row selected',
26+
notSelected: 'Row not selected'
27+
},
2428
placeholder: 'Search...',
2529
showingItems: 'Showing Items:',
2630
selectedItems: 'Selected Items:',

src/js/i18n/pl.js

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
description: 'Przeciągnij nagłówek kolumny tutaj, aby pogrupować według niej.'
2222
},
2323
search: {
24+
aria: {
25+
selected: 'Wiersz zaznaczony',
26+
notSelected: 'Wiersz niezaznaczony'
27+
},
2428
placeholder: 'Szukaj...',
2529
showingItems: 'Widoczne pozycje:',
2630
selectedItems: 'Zaznaczone pozycje:',

0 commit comments

Comments
 (0)