Skip to content

Commit 8f9a751

Browse files
vaadin-botweb-padawanclaude
authored
fix: pass content reset callback to GridMenuItem super constructor (#9906) (#9916)
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent caf9f55 commit 8f9a751

2 files changed

Lines changed: 81 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class GridMenuItem<T> extends
4747
*/
4848
public GridMenuItem(GridContextMenu<T> contextMenu,
4949
SerializableRunnable contentReset) {
50-
super(contextMenu);
50+
super(contextMenu, contentReset);
5151
Objects.requireNonNull(contextMenu);
5252
Objects.requireNonNull(contentReset);
5353
this.contentReset = contentReset;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright 2000-2026 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.component.grid.contextmenu;
17+
18+
import java.util.List;
19+
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.BeforeEach;
22+
import org.junit.jupiter.api.Test;
23+
import org.junit.jupiter.api.extension.RegisterExtension;
24+
25+
import com.vaadin.flow.component.grid.Grid;
26+
import com.vaadin.flow.component.internal.PendingJavaScriptInvocation;
27+
import com.vaadin.flow.component.shared.Tooltip.TooltipPosition;
28+
import com.vaadin.tests.MockUIExtension;
29+
30+
class GridMenuItemTest {
31+
32+
@RegisterExtension
33+
MockUIExtension ui = new MockUIExtension();
34+
35+
private GridContextMenu<String> contextMenu;
36+
private GridMenuItem<String> item;
37+
38+
@BeforeEach
39+
void setup() {
40+
Grid<String> grid = new Grid<>();
41+
contextMenu = grid.addContextMenu();
42+
item = contextMenu.addItem("item");
43+
ui.add(grid);
44+
ui.add(contextMenu);
45+
}
46+
47+
@Test
48+
void setTooltipText_menuContentGenerated() {
49+
flushPendingInvocations();
50+
51+
item.setTooltipText("tooltip");
52+
53+
Assertions.assertEquals(1, getGenerateItemsInvocations().size());
54+
}
55+
56+
@Test
57+
void setTooltipPosition_menuContentGenerated() {
58+
flushPendingInvocations();
59+
60+
item.setTooltipPosition(TooltipPosition.END);
61+
62+
Assertions.assertEquals(1, getGenerateItemsInvocations().size());
63+
}
64+
65+
private List<PendingJavaScriptInvocation> getGenerateItemsInvocations() {
66+
return getPendingInvocations()
67+
.stream().filter(invocation -> invocation.getInvocation()
68+
.getExpression().contains("$connector.generateItems"))
69+
.toList();
70+
}
71+
72+
private void flushPendingInvocations() {
73+
getPendingInvocations();
74+
}
75+
76+
private List<PendingJavaScriptInvocation> getPendingInvocations() {
77+
ui.fakeClientCommunication();
78+
return ui.dumpPendingJavaScriptInvocations();
79+
}
80+
}

0 commit comments

Comments
 (0)