瀏覽代碼

Compensate for (left) padding when setting size based on popup (#8313)

tags/7.0.0.alpha2
Leif Åstrand 12 年之前
父節點
當前提交
43bff90363
共有 1 個檔案被更改,包括 19 行新增1 行删除
  1. 19
    1
      src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java

+ 19
- 1
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");
}

/*

Loading…
取消
儲存