]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes removing all rows causing javascript error #13334
authorJohn Ahlroos <john@vaadin.com>
Thu, 7 Aug 2014 08:11:03 +0000 (11:11 +0300)
committerJohn Ahlroos <john@vaadin.com>
Thu, 7 Aug 2014 08:11:03 +0000 (11:11 +0300)
Change-Id: If3850d2248c6731bf3ee55d73c4cba2999ff9882

shared/src/com/vaadin/shared/ui/grid/Range.java
uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridStructureTest.java

index a1d4d86103bdfec9fb9b271ac5ccf76700f197b8..38b2ff2a60ce41f4c74df61b3b581516abcac087 100644 (file)
@@ -369,6 +369,12 @@ public final class Range implements Serializable {
      *             if the two ranges aren't connected
      */
     public Range combineWith(Range other) throws IllegalArgumentException {
+        if (other.isEmpty()) {
+            return this;
+        } else if (isEmpty()) {
+            return other;
+        }
+
         if (getStart() > other.getEnd() || other.getStart() > getEnd()) {
             throw new IllegalArgumentException("There is a gap between " + this
                     + " and " + other);
index 9ab2c98bdb71762f571cc7198d2a3e261b9fafce..8b3391253bf81dc70d17ccbff64ff9405c38b454 100644 (file)
@@ -521,6 +521,15 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
                         }
                     }
                 });
+
+        createClickAction("Remove all rows", "Body rows",
+                new Command<Grid, String>() {
+                    @SuppressWarnings("unchecked")
+                    @Override
+                    public void execute(Grid c, String value, Object data) {
+                        ds.removeAllItems();
+                    }
+                }, null);
     }
 
     @SuppressWarnings("boxing")
index ced6963c32595392fe4e1e3136fc7e1d8c17932c..d52f512b4f462a8be58247f68fe296a40bb65d33 100644 (file)
@@ -197,6 +197,16 @@ public class GridStructureTest extends GridBasicFeaturesTest {
                 "modified: Column 0", getBodyCellByRowAndColumn(0, 0).getText());
     }
 
+    @Test
+    public void testRemovingAllItems() throws Exception {
+        openTestURL();
+
+        selectMenuPath("Component", "Body rows", "Remove all rows");
+
+        assertEquals(0, getGridElement().findElement(By.tagName("tbody"))
+                .findElements(By.tagName("tr")).size());
+    }
+
     private void assertPrimaryStylename(String stylename) {
         assertTrue(getGridElement().getAttribute("class").contains(stylename));