From 6699834f741df04b2ca11d34852610de95609148 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 8 Apr 2010 07:43:19 +0000 Subject: [PATCH] Fix for #3846 - Empty string as a caption in VOrderedLayout uses space in IE6&7 but not in other browsers svn changeset:12373/svn branch:6.3 --- .../vaadin/terminal/gwt/client/VCaption.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/VCaption.java b/src/com/vaadin/terminal/gwt/client/VCaption.java index 201e1aaf87..8018875137 100644 --- a/src/com/vaadin/terminal/gwt/client/VCaption.java +++ b/src/com/vaadin/terminal/gwt/client/VCaption.java @@ -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(" "); } else { - placedAfterComponent = false; + DOM.setInnerText(captionText, c); } - DOM.setInnerText(captionText, c); + } else if (captionText != null) { // Remove existing DOM.removeChild(getElement(), captionText); -- 2.39.5