Incorrect `clickCount` in `ItemClickEvent` when using TestBench to click TreeGrid cells
@mcollovati is already working on this.
Since Apr 15, 2026.
Assessment
This issue has not been assessed yet.
Description
When using Vaadin TestBench to click cells in a TreeGrid, the clickCount reported in ItemClickEvent is always 0.
Clicking manually in the browser produces the correct value of 1.
However, doubleClick() and `click(0,0) are not affected by the issue.
A potential cause could be that click() uses a JavaScript click() call rather than Selenium Actions. Programmatic JavaScript clicks might not populate the clickCount field in browser events, which is why the value arrives as 0.
To reproduce use the following view and test
@Route("")
public class TreeGridIssueView extends HorizontalLayout {
public TreeGridIssueView() {
Div logs = new Div();
logs.setId("logs");
logs.setWidth("50%");
TreeGrid<Item> grid = new TreeGrid<>();
grid.setId("tree-grid");
grid.setHeight("500px");
grid.setWidth("50%");
grid.setWidth("50%");
grid.addHierarchyColumn(Item::name).setHeader("Name").setWidth("300px");
grid.addColumn(Item::size).setHeader("Size");
grid.setTreeData(createTreeDataSample());
grid.addItemClickListener(event -> logs.add(new Div(
createLogMessage(event.getItem().name(), event.getColumn().getHeaderText(), event.getClickCount()))
));
add(grid, logs);
}
record Item(String name, long size, List<Item> children) {
}
static TreeData<Item> createTreeDataSample() {
TreeData<Item> data = new TreeData<>();
Item dirA = new Item("Directory A", 150, List.of(
new Item("File A", 50, List.of()),
new Item("File B", 50, List.of())
));
Item dirB = new Item("Directory B", 400, List.of(
new Item("File D", 250, List.of())
));
data.addItems(List.of(dirA, dirB), Item::children);
return data;
}
static String createLogMessage(String item, String column, int expectedCount) {
return String.format("clicked %s; column: %s; clickCount: %d",
item, column, expectedCount);
}
}
public class TreeGridIssueIT extends BrowserTestBase {
@BeforeEach
public void open() {
getDriver().get("http://localhost:8080/");
}
@BrowserTest
public void testClickTreeGridCell() {
TreeGridElement grid = $(TreeGridElement.class).waitForFirst();
GridColumnElement col1 = grid.getVisibleColumns().get(0);
grid.getRow(0).getCell(col1).click();
assertClickListenerExecuted("Directory A", "Name", 1);
}
@BrowserTest
public void testClickXYTreeGridCell() {
TreeGridElement grid = $(TreeGridElement.class).waitForFirst();
GridColumnElement col1 = grid.getVisibleColumns().get(0);
grid.getRow(0).getCell(col1).click(0,0);
assertClickListenerExecuted("Directory A", "Name", 1);
}
@BrowserTest
public void testDoubleClickTreeGridCell() {
TreeGridElement grid = $(TreeGridElement.class).waitForFirst();
GridColumnElement col1 = grid.getVisibleColumns().get(0);
grid.getRow(0).getCell(col1).doubleClick();
assertClickListenerExecuted("Directory A", "Name", 2);
}
private void assertClickListenerExecuted(String item, String column, int expectedCount) {
var lastMessage = waitUntil(d -> $(DivElement.class).id("logs")
.$(DivElement.class).last()).getText();
Assertions.assertEquals(TreeGridIssueView.createLogMessage(item, column, expectedCount), lastMessage);
}
}
- Dominant language
- Java
- Stars
- 25
- Forks
- 25
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 44
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vaadin/testbench
-
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
load testing
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
documentation
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in vaadin/testbench
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
objectionary/hone-maven-plugin#1061 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
spring-projects/spring-modulith#1895 ·