diff --git a/README.md b/README.md
index 2ecee14..0063f9e 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,10 @@ The integration tests are in. These mainly cover some user interaction that cann
## Release notes
+### 3.1.4
+
+- Fix A11y metadata update upon programmatic selection
+
### 3.1.3
- Added an alert text for "No data" when the table is empty
diff --git a/pom.xml b/pom.xml
index 54f8602..24ed88a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
org.vaadin.tatu
beantable
- 3.1.3
+ 3.1.4
BeanTable
Table component for Vaadin platform
diff --git a/src/main/java/org/vaadin/tatu/BeanTable.java b/src/main/java/org/vaadin/tatu/BeanTable.java
index 714b86d..323e7f0 100644
--- a/src/main/java/org/vaadin/tatu/BeanTable.java
+++ b/src/main/java/org/vaadin/tatu/BeanTable.java
@@ -520,7 +520,8 @@ private void createCells() {
}
}
if (selectionEnabled) {
- cell.setAttribute("aria-selected", "false");
+ cell.setAttribute("aria-selected",
+ selected.contains(item) ? "true" : "false");
}
if (!column.isVisible()) {
cell.getStyle().set("display", "none");
@@ -614,7 +615,7 @@ public BeanTable() {
menuButton.setVisible(false);
runBeforeClientResponse(ui -> {
setNoData();
- });
+ });
}
private void enableKeyboardNavigation() {
@@ -1769,7 +1770,7 @@ public static BeanTableI18n getDefault() {
english.setPreviousPage("Previous page");
english.setMenuButton("Column selector");
english.setErrorText("Failed fetching data");
- english.setNoDataText("No data");
+ english.setNoDataText("No data");
english.setPageProvider((currentPage, lastPage) -> "Page "
+ currentPage + " of " + lastPage);
return english;
diff --git a/src/test/java/org/vaadin/tatu/BeanTableTest.java b/src/test/java/org/vaadin/tatu/BeanTableTest.java
index cfbf55e..6623e2d 100644
--- a/src/test/java/org/vaadin/tatu/BeanTableTest.java
+++ b/src/test/java/org/vaadin/tatu/BeanTableTest.java
@@ -797,6 +797,7 @@ public void selection() {
.mapToObj(i -> new DataItem("name" + i, "data" + i))
.collect(Collectors.toList());
table.setItems(items);
+ table.setSelectionEnabled(true);
selected = null;
count = 0;
@@ -880,25 +881,36 @@ public void errorTable() {
ui.add(table);
- Assert.assertEquals("Failed fetching data",
- table.bodyElement.getChild(0).getChild(0).getText());
+ Element alertCell = table.bodyElement.getChild(0).getChild(0);
+ Assert.assertEquals("Failed fetching data", alertCell.getText());
+ Assert.assertEquals("alert", alertCell.getAttribute("role"));
+ Assert.assertEquals("assertive", alertCell.getAttribute("aria-live"));
+ Assert.assertEquals("3", alertCell.getAttribute("colspan"));
}
private void assertSelectedThemeSet(BeanTable table,
int... items) {
for (int item : items) {
+ Element row = table.bodyElement.getChild(item);
Assert.assertEquals("item at index " + item + " should be selected",
"selected",
- table.bodyElement.getChild(item).getAttribute("theme"));
+ row.getAttribute("theme"));
+ for (int i=1;i table,
int... items) {
for (int item : items) {
+ Element row = table.bodyElement.getChild(item);
Assert.assertEquals(
"item at index " + item + " should not be selected", null,
- table.bodyElement.getChild(item).getAttribute("theme"));
+ row.getAttribute("theme"));
+ for (int i=1;i