From 5901b75dcacbe16a6af8d38df621864fbf107bcd Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Thu, 10 Jan 2013 16:38:12 +0200 Subject: [PATCH] Fixed issue with IE8 forgetting to re-render a slots height when child changes size #10588 Change-Id: I5476cc36590ea01befb8b22eec2a25675836badf --- .../vaadin/client/ui/orderedlayout/Slot.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java index b59c3664c7..8cec3f755a 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java @@ -18,14 +18,17 @@ package com.vaadin.client.ui.orderedlayout; import java.util.List; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.UIObject; import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.BrowserInfo; import com.vaadin.client.LayoutManager; import com.vaadin.client.StyleConstants; +import com.vaadin.client.ui.layout.ElementResizeEvent; import com.vaadin.client.ui.layout.ElementResizeListener; import com.vaadin.shared.ui.AlignmentInfo; @@ -92,6 +95,25 @@ public final class Slot extends SimplePanel { private ElementResizeListener spacingResizeListener; + /* + * IE8 forgets to re-render the slot if the widget inside the slot changes + * size. To force IE to re-render we apply the well know zoom property to + * the widget which triggers a re-render of the slot element. + */ + private static final ElementResizeListener ie8ElementRefresherListener = new ElementResizeListener() { + + @Override + public void onElementResize(final ElementResizeEvent e) { + Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { + @Override + public void execute() { + int zoom = e.getElement().getPropertyInt("zoom"); + e.getElement().setPropertyInt("zoom", zoom); + } + }); + } + }; + // Caption is placed after component unless there is some part which // moves it above. private CaptionPosition captionPosition = CaptionPosition.RIGHT; @@ -160,6 +182,11 @@ public final class Slot extends SimplePanel { lm.addElementResizeListener(getSpacingElement(), spacingResizeListener); } + + if (BrowserInfo.get().isIE8()) { + lm.addElementResizeListener(getWidget().getElement(), + ie8ElementRefresherListener); + } } } @@ -181,6 +208,11 @@ public final class Slot extends SimplePanel { lm.removeElementResizeListener(getSpacingElement(), spacingResizeListener); } + + if (BrowserInfo.get().isIE8()) { + lm.removeElementResizeListener(getWidget().getElement(), + ie8ElementRefresherListener); + } } } -- 2.39.5