Skip to content

Commit 2844561

Browse files
web-padawanclaude
andauthored
feat: add selectAllUnavailable to GridI18n (#9729)
The Grid web component added a new `selectAllUnavailable` i18n property in vaadin/web-components#12080. It provides the accessible name announced for the selection column header cell when the select all checkbox is hidden (e.g. a data provider is used or conditional selection is enabled). This property was missing from the Flow `GridI18n` API, so Flow users could not customize or translate it. This adds a matching `selectAllUnavailable` getter/setter to `GridI18n`, following the existing pattern of the other accessible-name properties. Part of vaadin/web-components#12080 --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 04893e0 commit 2844561

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

  • vaadin-grid-flow-parent/vaadin-grid-flow/src

‎vaadin-grid-flow-parent/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/GridI18n.java‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
@JsonInclude(JsonInclude.Include.NON_NULL)
3232
public class GridI18n implements Serializable {
3333
private String selectAll;
34+
private String selectAllUnavailable;
3435
private String selectRow;
3536
private String sorter;
3637

@@ -57,6 +58,35 @@ public GridI18n setSelectAll(String selectAll) {
5758
return this;
5859
}
5960

61+
/**
62+
* Gets the accessible name announced for the selection column header cell
63+
* when the select all checkbox is hidden (e.g. a data provider is used or
64+
* conditional selection is enabled), rendered as a screen-reader-only label
65+
* in the cell.
66+
*
67+
* @return the accessible name for the header cell when select all is
68+
* unavailable
69+
*/
70+
public String getSelectAllUnavailable() {
71+
return selectAllUnavailable;
72+
}
73+
74+
/**
75+
* Sets the accessible name announced for the selection column header cell
76+
* when the select all checkbox is hidden (e.g. a data provider is used or
77+
* conditional selection is enabled), rendered as a screen-reader-only label
78+
* in the cell.
79+
*
80+
* @param selectAllUnavailable
81+
* the accessible name for the header cell when select all is
82+
* unavailable
83+
* @return this instance for method chaining
84+
*/
85+
public GridI18n setSelectAllUnavailable(String selectAllUnavailable) {
86+
this.selectAllUnavailable = selectAllUnavailable;
87+
return this;
88+
}
89+
6090
/**
6191
* Gets the accessible name (aria-label) template for the select row
6292
* checkbox in each selection column body cell.

‎vaadin-grid-flow-parent/vaadin-grid-flow/src/test/java/com/vaadin/flow/component/grid/GridI18nTest.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class GridI18nTest {
2424
void defaultValues_areNull() {
2525
GridI18n i18n = new GridI18n();
2626
Assertions.assertNull(i18n.getSelectAll());
27+
Assertions.assertNull(i18n.getSelectAllUnavailable());
2728
Assertions.assertNull(i18n.getSelectRow());
2829
Assertions.assertNull(i18n.getSorter());
2930
}
@@ -32,6 +33,8 @@ void defaultValues_areNull() {
3233
void setters_returnSameInstance() {
3334
GridI18n i18n = new GridI18n();
3435
Assertions.assertSame(i18n, i18n.setSelectAll("Select all"));
36+
Assertions.assertSame(i18n,
37+
i18n.setSelectAllUnavailable("Select All unavailable"));
3538
Assertions.assertSame(i18n,
3639
i18n.setSelectRow("Select row {rowHeader}"));
3740
Assertions.assertSame(i18n, i18n.setSorter("Sort by {column}"));
@@ -40,9 +43,12 @@ void setters_returnSameInstance() {
4043
@Test
4144
void setters_updateValues() {
4245
GridI18n i18n = new GridI18n().setSelectAll("Select all")
46+
.setSelectAllUnavailable("Select All unavailable")
4347
.setSelectRow("Select row {rowHeader}")
4448
.setSorter("Sort by {column}");
4549
Assertions.assertEquals("Select all", i18n.getSelectAll());
50+
Assertions.assertEquals("Select All unavailable",
51+
i18n.getSelectAllUnavailable());
4652
Assertions.assertEquals("Select row {rowHeader}", i18n.getSelectRow());
4753
Assertions.assertEquals("Sort by {column}", i18n.getSorter());
4854
}
@@ -70,11 +76,14 @@ void grid_setI18n_null_throws() {
7076
void grid_setI18n_setsElementProperty() {
7177
Grid<String> grid = new Grid<>();
7278
grid.setI18n(new GridI18n().setSelectAll("Select all")
79+
.setSelectAllUnavailable("Select All unavailable")
7380
.setSelectRow("Select row {rowHeader}")
7481
.setSorter("Sort by {column}"));
7582

7683
String json = grid.getElement().getPropertyRaw("i18n").toString();
7784
Assertions.assertTrue(json.contains("\"selectAll\":\"Select all\""));
85+
Assertions.assertTrue(json.contains(
86+
"\"selectAllUnavailable\":\"Select All unavailable\""));
7887
Assertions.assertTrue(
7988
json.contains("\"selectRow\":\"Select row {rowHeader}\""));
8089
Assertions.assertTrue(json.contains("\"sorter\":\"Sort by {column}\""));

0 commit comments

Comments
 (0)