aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2021-03-08 13:18:11 +0200
committerGitHub <noreply@github.com>2021-03-08 13:18:11 +0200
commit7eb9588359c28ed484bcaeb729fc54675601671a (patch)
treec8aeb6d5f6b323ad277fe2266e6e574461a23d1a /uitest/src/main
parentff41bba3d7d0d8c02570b8dfccb413295e091708 (diff)
downloadvaadin-framework-7eb9588359c28ed484bcaeb729fc54675601671a.tar.gz
vaadin-framework-7eb9588359c28ed484bcaeb729fc54675601671a.zip
Fix updating Grid's item set when details rows are open. (#12231)
- Old details should close. - New details should open. - If some row has details in both old and new item set, the details row contents should get updated. - Updating details row contents should not break the positioning of the rows and details below. Fixes #12211
Diffstat (limited to 'uitest/src/main')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsUpdateItems.java74
-rw-r--r--uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorProxy.java5
2 files changed, 79 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsUpdateItems.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsUpdateItems.java
new file mode 100644
index 0000000000..d84e0466a9
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsUpdateItems.java
@@ -0,0 +1,74 @@
+package com.vaadin.tests.components.grid;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import com.vaadin.data.ValueProvider;
+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.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class GridDetailsUpdateItems extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponent(createExamplleLayout());
+ }
+
+ private VerticalLayout createExamplleLayout() {
+ Collection<String> firstCollection = Arrays.asList("Hello", ",",
+ "world!");
+ Collection<String> secondCollection = Arrays.asList("My", "name", "is",
+ "Sarah");
+ Collection<String> thirdCollection = Arrays.asList("red", "blue");
+ Collection<String> fourthCollection = Arrays.asList("spring", "summer",
+ "autumn", "winter");
+
+ VerticalLayout mainLayout = new VerticalLayout();
+ Grid<Collection<String>> grid = new Grid<>();
+ grid.setDetailsGenerator(collection -> {
+ VerticalLayout detailLayout = new VerticalLayout();
+ collection.forEach(
+ item -> detailLayout.addComponent(new Label(item)));
+ return detailLayout;
+ });
+ ValueProvider<Collection<String>, String> valueProvider = collection -> String
+ .join(" ", collection);
+ grid.addColumn(valueProvider).setCaption("Header");
+
+ List<Collection<String>> itemsInitial = Arrays.asList(firstCollection,
+ secondCollection, thirdCollection, fourthCollection);
+ grid.setItems(itemsInitial);
+ for (Collection<String> tmp : itemsInitial) {
+ grid.setDetailsVisible(tmp, true);
+ }
+ mainLayout.addComponent(grid);
+
+ Button clickButton = new Button("Change items", event -> {
+ List<Collection<String>> itemsOverwrite = Arrays
+ .asList(secondCollection, fourthCollection);
+ grid.setItems(itemsOverwrite);
+ for (Collection<String> tmp : itemsOverwrite) {
+ grid.setDetailsVisible(tmp, true);
+ }
+ });
+ mainLayout.addComponent(clickButton);
+
+ return mainLayout;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12211;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Details should update and not break the positioning "
+ + "when the item set is changed.";
+ }
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorProxy.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorProxy.java
index 65fe75e9fa..404556f2d6 100644
--- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorProxy.java
+++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorProxy.java
@@ -117,6 +117,11 @@ public class EscalatorProxy extends Escalator {
}
@Override
+ public void resetSpacer(int rowIndex) {
+ rowContainer.resetSpacer(rowIndex);
+ }
+
+ @Override
public void setSpacerUpdater(SpacerUpdater spacerUpdater)
throws IllegalArgumentException {
rowContainer.setSpacerUpdater(spacerUpdater);