]> source.dussan.org Git - vaadin-framework.git/commitdiff
Compensate for (left) padding when setting size based on popup (#8313)
authorLeif Åstrand <leif@vaadin.com>
Thu, 23 Feb 2012 18:58:51 +0000 (20:58 +0200)
committerLeif Åstrand <leif@vaadin.com>
Thu, 23 Feb 2012 18:58:51 +0000 (20:58 +0200)
src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java

index d4d9e99dea40a0513a46744e3fb5c80396f7d3e5..ac0db6992c78c721f0794730857fe42664bd4534 100644 (file)
@@ -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");
             }
 
             /*