]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for #3846 - Empty string as a caption in VOrderedLayout uses space in IE6&7 but...
authorArtur Signell <artur.signell@itmill.com>
Thu, 8 Apr 2010 07:43:19 +0000 (07:43 +0000)
committerArtur Signell <artur.signell@itmill.com>
Thu, 8 Apr 2010 07:43:19 +0000 (07:43 +0000)
svn changeset:12373/svn branch:6.3

src/com/vaadin/terminal/gwt/client/VCaption.java

index 201e1aaf87a3f5bc31f09892e41a0df1ffeb0901..8018875137adf1d70a70fcd7c317d9e2d2af442c 100644 (file)
@@ -73,6 +73,8 @@ public class VCaption extends HTML {
 
         boolean wasPlacedAfterComponent = placedAfterComponent;
 
+        // Caption is placed after component unless there is some part which
+        // moves it above.
         placedAfterComponent = true;
 
         String style = CLASSNAME;
@@ -98,6 +100,7 @@ public class VCaption extends HTML {
                 DOM.insertChild(getElement(), icon.getElement(),
                         getInsertPosition(ATTRIBUTE_ICON));
             }
+            // Icon forces the caption to be above the component
             placedAfterComponent = false;
 
             iconOnloadHandled = false;
@@ -110,6 +113,10 @@ public class VCaption extends HTML {
         }
 
         if (uidl.hasAttribute(ATTRIBUTE_CAPTION)) {
+            // A caption text should be shown if the attribute is set
+            // If the caption is null the ATTRIBUTE_CAPTION should not be set to
+            // avoid ending up here.
+
             if (captionText == null) {
                 captionText = DOM.createDiv();
                 captionText.setClassName("v-captiontext");
@@ -120,12 +127,18 @@ public class VCaption extends HTML {
 
             // Update caption text
             String c = uidl.getStringAttribute(ATTRIBUTE_CAPTION);
-            if (c == null) {
-                c = "";
+            // A text forces the caption to be above the component.
+            placedAfterComponent = false;
+            if (c == null || c.trim().equals("")) {
+                // Not sure if c even can be null. Should not.
+
+                // This is required to ensure that the caption uses space in all
+                // browsers when it is set to the empty string.
+                captionText.setInnerHTML("&nbsp;");
             } else {
-                placedAfterComponent = false;
+                DOM.setInnerText(captionText, c);
             }
-            DOM.setInnerText(captionText, c);
+
         } else if (captionText != null) {
             // Remove existing
             DOM.removeChild(getElement(), captionText);