]> source.dussan.org Git - vaadin-framework.git/commitdiff
#3991 Select with icons shown wrong in IE8 upon first render
authorArtur Signell <artur.signell@itmill.com>
Tue, 18 Jan 2011 14:52:03 +0000 (14:52 +0000)
committerArtur Signell <artur.signell@itmill.com>
Tue, 18 Jan 2011 14:52:03 +0000 (14:52 +0000)
svn changeset:16934/svn branch:6.5

src/com/vaadin/terminal/gwt/client/Util.java
src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java

index e21be19fac01cd774c9b9b9c5b51a12d22ef67e7..cd8bef0341fb9e79ce552e79870d564f1f36079f 100644 (file)
@@ -13,6 +13,7 @@ import java.util.Set;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
 import com.google.gwt.dom.client.DivElement;
 import com.google.gwt.dom.client.Document;
 import com.google.gwt.dom.client.Node;
@@ -1018,4 +1019,31 @@ public class Util {
         }
     }
 
+    /**
+     * Temporarily sets the {@code styleProperty} to {@code tempValue} and then
+     * resets it to its current value. Used mainly to work around rendering
+     * issues in IE (and possibly in other browsers)
+     * 
+     * @param element
+     *            The target element
+     * @param styleProperty
+     *            The name of the property to set
+     * @param tempValue
+     *            The temporary value
+     */
+    public static void setStyleTemporarily(Element element,
+            final String styleProperty, String tempValue) {
+        final Style style = element.getStyle();
+        final String currentValue = style.getProperty(styleProperty);
+
+        style.setProperty(styleProperty, tempValue);
+        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
+
+            public void execute() {
+                style.setProperty(styleProperty, currentValue);
+            }
+        });
+
+    }
+
 }
index 0d9ba336a1f2618d65904ab5e2334306fbc87e82..01d2722c9cfbdcce0e4c2eb2aae8d57283261f8f 100644 (file)
@@ -817,22 +817,11 @@ public class VFilterSelect extends Composite implements Paintable, Field,
             public void onLoad(LoadEvent event) {
                 updateRootWidth();
                 updateSelectedIconPosition();
-
                 /*
-                 * We need to re-calculate the widths in IE at load time to
-                 * ensure that the text is not placed behind the icon. #3991
+                 * Force IE to recalculate the position of the text (#3991)
                  */
                 if (BrowserInfo.get().isIE()) {
-                    int tbWidth = Util.getRequiredWidth(tb);
-                    int openerWidth = Util.getRequiredWidth(popupOpener);
-                    int iconWidth = selectedItemIcon.isAttached() ? Util
-                            .measureMarginLeft(tb.getElement())
-                            - Util.measureMarginLeft(selectedItemIcon
-                                    .getElement()) : 0;
-
-                    int w = tbWidth + openerWidth + iconWidth;
-                    tb.setWidth((tbWidth - getTextboxPadding()) + "px");
-                    setTextboxWidth(w);
+                    Util.setStyleTemporarily(tb.getElement(), "paddingLeft", "0");
                 }
             }
         });