aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2021-06-30 11:53:18 +0300
committerGitHub <noreply@github.com>2021-06-30 11:53:18 +0300
commit347d36dcbccb07f1dd46f17ea5be6fceecc755cb (patch)
treea16bca23797f2d92cb3f06d4540c19a76fefa5bb /uitest/src/main/java/com
parentf70bc4269c264214f0ab8ac637df877ded55bddf (diff)
downloadvaadin-framework-347d36dcbccb07f1dd46f17ea5be6fceecc755cb.tar.gz
vaadin-framework-347d36dcbccb07f1dd46f17ea5be6fceecc755cb.zip
Ensure removing a row does not cause exceptions in detail row handling. (#12330)
Fixes: #12328
Diffstat (limited to 'uitest/src/main/java/com')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridRemoveItemAllDetailsOpen.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridRemoveItemAllDetailsOpen.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridRemoveItemAllDetailsOpen.java
new file mode 100644
index 0000000000..55a604971d
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridRemoveItemAllDetailsOpen.java
@@ -0,0 +1,63 @@
+package com.vaadin.tests.components.grid;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.vaadin.data.provider.ListDataProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+
+public class GridRemoveItemAllDetailsOpen extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ List<String> data = new ArrayList<>(
+ Arrays.asList("row1", "row2", "row3", "row4"));
+ Grid<String> grid = createGrid();
+
+ ListDataProvider<String> dataProvider = new ListDataProvider<>(data);
+ grid.setDataProvider(dataProvider);
+ data.forEach(item -> grid.setDetailsVisible(item, true));
+
+ Button removeBtn = new Button("Remove selected item");
+ removeBtn.addClickListener(event -> {
+ data.remove(grid.getSelectedItems().iterator().next());
+ dataProvider.refreshAll();
+ grid.deselectAll();
+ });
+ addComponent(removeBtn);
+ addComponent(grid);
+ }
+
+ private Grid<String> createGrid() {
+ Grid<String> grid = new Grid<>();
+ grid.setHeight("400px");
+ grid.addColumn(item -> item).setCaption("column").setId("column");
+ grid.setDetailsGenerator(item -> {
+ Button closeBtn = new Button("Close");
+ closeBtn.addClickListener(
+ clickEvent -> grid.setDetailsVisible(item, false));
+ return new HorizontalLayout(new Label("Item details: " + item),
+ closeBtn);
+ });
+ grid.addItemClickListener(
+ itemClick -> grid.setDetailsVisible(itemClick.getItem(), true));
+ return grid;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12328;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Removing selected item (first or second)"
+ + "should not cause a client side exception.";
+ }
+}