From 688910a21db5f3b71bb9bdf9343e62d9277ae6c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Fri, 23 Mar 2012 10:35:11 +0200 Subject: [PATCH] Force more reflows in IE8 to detect icon style (#8313) --- .../terminal/gwt/client/ui/VFilterSelect.java | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index a3c273260e..a7a12df840 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -1150,16 +1150,35 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, if (iconUri == null || iconUri.length() == 0) { if (selectedItemIcon.isAttached()) { panel.remove(selectedItemIcon); + if (BrowserInfo.get().isIE8()) { + forceReflow(); + } updateRootWidth(); } } else { - panel.insert(selectedItemIcon, 0); selectedItemIcon.setUrl(iconUri); + panel.insert(selectedItemIcon, 0); + if (BrowserInfo.get().isIE8()) { + forceReflow(); + } updateRootWidth(); updateSelectedIconPosition(); } } + private void forceReflow() { + Style style = tb.getElement().getStyle(); + + String oldZoom = style.getProperty("zoom"); + style.setProperty("zoom", "1"); + + // Forces reflow because style has changed + tb.getOffsetWidth(); + + // Restore old style + style.setProperty("zoom", oldZoom); + } + /** * Positions the icon vertically in the middle. Should be called after the * icon has loaded @@ -1605,20 +1624,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * Lock the textbox width to its current value if it's not already * locked */ - Style style = tb.getElement().getStyle(); - if (!style.getWidth().endsWith("px")) { - boolean isIE8 = BrowserInfo.get().isIE8(); - if (isIE8) { - // Must do something to make IE8 realize that it should - // reflow the component when the offset width is read - style.setProperty("zoom", "1"); - } + if (!tb.getElement().getStyle().getWidth().endsWith("px")) { tb.setWidth((tb.getOffsetWidth() - selectedItemIcon .getOffsetWidth()) + "px"); - if (isIE8) { - // Restore old style property value - style.clearProperty("zoom"); - } } } } -- 2.39.5