if (sortable) {
cellElement.addClassName("sortable");
+ cellElement.setAttribute("aria-sort", "none");
}
if (!sortable || sortingOrder == null) {
if (SortDirection.ASCENDING == sortingOrder.getDirection()) {
cellElement.addClassName("sort-asc");
+ cellElement.setAttribute("aria-sort", "ascending");
} else {
cellElement.addClassName("sort-desc");
+ cellElement.setAttribute("aria-sort", "descending");
}
int sortIndex = Grid.this.getSortOrder().indexOf(sortingOrder);
if (sortIndex > -1 && Grid.this.getSortOrder().size() > 1) {
// Show sort order indicator if column is
// sorted and other sorted columns also exists.
- cellElement.setAttribute("sort-order",
- String.valueOf(sortIndex + 1));
+ cellElement.setAttribute("sort-order", String.valueOf(sortIndex + 1));
+ cellElement.setAttribute("aria-sort", "other");
}
if (!sortedBefore) {
private void cleanup(FlyweightCell cell) {
Element cellElement = cell.getElement();
cellElement.removeAttribute("sort-order");
+ cellElement.removeAttribute("aria-sort");
cellElement.removeClassName("sort-desc");
cellElement.removeClassName("sort-asc");
cellElement.removeClassName("sortable");
Assert.assertTrue("First column should be sorted ascending",
grid.getHeaderCell(0, 0).getAttribute("class")
.contains("sort-asc"));
+ Assert.assertEquals("First column should have aria-sort other", "other",
+ grid.getHeaderCell(0, 0).getAttribute("aria-sort"));
Assert.assertEquals("First column should be first in sort order", "1",
grid.getHeaderCell(0, 0).getAttribute("sort-order"));
Assert.assertTrue("Second column should be sorted ascending",
grid.getHeaderCell(0, 1).getAttribute("class")
.contains("sort-asc"));
+ Assert.assertEquals("Second column should have aria-sort other", "other",
+ grid.getHeaderCell(0, 1).getAttribute("aria-sort"));
Assert.assertEquals("Second column should be also sorted", "2",
grid.getHeaderCell(0, 1).getAttribute("sort-order"));
$(ButtonElement.class).caption("Sort first").first().click();
+ Assert.assertEquals("First column should have aria-sort ascending", "ascending",
+ grid.getHeaderCell(0, 0).getAttribute("aria-sort"));
Assert.assertTrue("First column should be sorted ascending",
grid.getHeaderCell(0, 0).getAttribute("class")
.contains("sort-asc"));
+ Assert.assertEquals("Second column should have aria-sort none", "none",
+ grid.getHeaderCell(0, 1).getAttribute("aria-sort"));
Assert.assertFalse("Second column should not be sorted",
grid.getHeaderCell(0, 1).getAttribute("class")
.contains("sort-asc"));