Skip to content

Commit

Permalink
Version 3.1.4: Fix A11y metadata update upon programmatic selection
Browse files Browse the repository at this point in the history
  • Loading branch information
TatuLund committed May 9, 2023
1 parent 2f5d939 commit 5558f5b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.vaadin.tatu</groupId>
<artifactId>beantable</artifactId>
<version>3.1.3</version>
<version>3.1.4</version>
<name>BeanTable</name>
<description>Table component for Vaadin platform</description>
<properties>
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/vaadin/tatu/BeanTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -614,7 +615,7 @@ public BeanTable() {
menuButton.setVisible(false);
runBeforeClientResponse(ui -> {
setNoData();
});
});
}

private void enableKeyboardNavigation() {
Expand Down Expand Up @@ -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;
Expand Down
20 changes: 16 additions & 4 deletions src/test/java/org/vaadin/tatu/BeanTableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<DataItem> 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<row.getChildCount();i++) {
Assert.assertEquals("true", row.getChild(i).getAttribute("aria-selected"));
}
}
}

private void assertSelectedThemeNotSet(BeanTable<DataItem> 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<row.getChildCount();i++) {
Assert.assertEquals("false", row.getChild(i).getAttribute("aria-selected"));
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/vaadin/tatu/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public View() {
newData.setText("Add " + nextYear);
});
RouterLink lazy = new RouterLink("Lazy load demo", LazyView.class);

table.focus();
add(plus, minus, table, newData, lazy);
}
Expand Down

0 comments on commit 5558f5b

Please sign in to comment.