Browse Source

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

tags/7.0.0.alpha2
Leif Åstrand 12 years ago
parent
commit
43bff90363
1 changed files with 19 additions and 1 deletions
  1. 19
    1
      src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java

+ 19
- 1
src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java View 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");
}

/*

Loading…
Cancel
Save