From: Leif Åstrand Date: Thu, 23 Feb 2012 18:58:51 +0000 (+0200) Subject: Compensate for (left) padding when setting size based on popup (#8313) X-Git-Tag: 7.0.0.alpha2~434^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=43bff90363a786ff7087719736c49daa4ee21d50;p=vaadin-framework.git Compensate for (left) padding when setting size based on popup (#8313) --- diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index d4d9e99dea..ac0db6992c 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -13,6 +13,8 @@ import java.util.List; import java.util.Set; import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.ClickEvent; @@ -1574,7 +1576,23 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, int w = Util.getRequiredWidth(this); if ((!initDone || currentPage + 1 < 0) && suggestionPopupMinWidth > w) { - setWidth(suggestionPopupMinWidth + "px"); + /* + * We want to compensate for the paddings just to preserve the + * exact size as in Vaadin 6.x, but we get here before + * MeasuredSize has been initialized. + * Util.measureHorizontalPaddingAndBorder does not work with + * border-box, so we must do this the hard way. + */ + Style style = getElement().getStyle(); + String originalPadding = style.getPadding(); + String originalBorder = style.getBorderWidth(); + style.setPaddingLeft(0, Unit.PX); + style.setBorderWidth(0, Unit.PX); + int offset = w - Util.getRequiredWidth(this); + style.setProperty("padding", originalPadding); + style.setProperty("borderWidth", originalBorder); + + setWidth(suggestionPopupMinWidth + offset + "px"); } /*