]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes VTree so that you can click sub elements when setHtmlContentAllowed is true...
authorSebastian Nyholm <sebastian@vaadin.com>
Mon, 26 Sep 2016 11:24:12 +0000 (14:24 +0300)
committerSebastian Nyholm <sebastian@vaadin.com>
Mon, 26 Sep 2016 11:34:31 +0000 (14:34 +0300)
Change-Id: Ic453aaf16ea1d44792db868e04faaba069aab3b7

client/src/main/java/com/vaadin/client/ui/VTree.java
uitest/src/main/java/com/vaadin/tests/components/tree/TreeHtmlContentAllowed.java
uitest/src/test/java/com/vaadin/tests/components/tree/TreeHtmlContentAllowedTest.java

index 7f83548010e358137c4543b854619c4cedeeff15..68211d023d203d1903a0ad55c479aaa2c23f75eb 100644 (file)
@@ -818,7 +818,7 @@ public class VTree extends FocusElementPanel
          */
         public boolean isCaptionElement(
                 com.google.gwt.dom.client.Element target) {
-            return (target == nodeCaptionSpan
+            return (nodeCaptionSpan.isOrHasChild(target)
                     || (icon != null && target == icon.getElement()));
         }
 
index e381c5c35815d8fe65defa1d605457f90438acb8..62ee5c1e9ecbaaeb15c7746ddfef82b800e9b0ae 100644 (file)
@@ -30,18 +30,20 @@ public class TreeHtmlContentAllowed extends AbstractTestUI {
         String htmlParent = "Some <b>html</b>";
         String textChild = "Child text";
         String htmlChild = "Child <i>html</i>";
+        String htmlElementChild = "Child <span id='my-html-element'>element html</span>";
 
         final Tree tree = new Tree("A tree");
         tree.addItem(textParent);
         tree.addItem(htmlParent);
         tree.addItem(textChild);
         tree.addItem(htmlChild);
-
+        tree.addItem(htmlElementChild);
         tree.setParent(textChild, textParent);
         tree.setParent(htmlChild, htmlParent);
 
         tree.setChildrenAllowed(textChild, false);
         tree.setChildrenAllowed(htmlChild, false);
+        tree.setChildrenAllowed(htmlElementChild, false);
 
         final CheckBox toggle = new CheckBox("HTML content allowed",
                 tree.isHtmlContentAllowed());
index fd5c0a730ca16d3137c21138708b954146ef4854..0afc15a1b126f70158bf1cf4d7802430628fed65 100644 (file)
@@ -37,19 +37,32 @@ public class TreeHtmlContentAllowedTest extends SingleBrowserTest {
                 "unchecked", toggle.getValue());
 
         // Markup is seen as plain text
-        assertTreeCaptionTexts("Just text", "Some <b>html</b>");
+        assertTreeCaptionTexts("Just text", "Some <b>html</b>",
+                "Child <span id='my-html-element'>element html</span>");
 
         toggle.click();
-        assertTreeCaptionTexts("Just text", "Some html");
+        assertTreeCaptionTexts("Just text", "Some html", "Child element html");
 
         // Expand the HTML parent
         findElements(By.className("v-tree-node")).get(1).click();
 
-        assertTreeCaptionTexts("Just text", "Some html", "Child html");
+        assertTreeCaptionTexts("Just text", "Some html", "Child html",
+                "Child element html");
 
         toggle.click();
         assertTreeCaptionTexts("Just text", "Some <b>html</b>",
-                "Child <i>html</i>");
+                "Child <i>html</i>",
+                "Child <span id='my-html-element'>element html</span>");
+
+        toggle.click();
+        findElements(By.id("my-html-element")).get(0).click();
+        assertHtmlElementSelected();
+
+    }
+
+    private void assertHtmlElementSelected() {
+        TreeElement tree = $(TreeElement.class).first();
+        Assert.assertEquals(tree.getValue(), "Child element html");
     }
 
     private void assertTreeCaptionTexts(String... captions) {