Browse Source

Fix for #2974

svn changeset:13959/svn branch:6.4
tags/6.7.0.beta1
John Alhroos 14 years ago
parent
commit
2056d9d955
1 changed files with 43 additions and 4 deletions
  1. 43
    4
      src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java

+ 43
- 4
src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java View File

@@ -793,6 +793,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
private int textboxPadding = -1;
private int componentPadding = -1;
private int suggestionPopupMinWidth = 0;
private int popupWidth = -1;
/*
* Stores the last new item string to avoid double submissions. Cleared on
* uidl updates
@@ -1055,11 +1056,29 @@ public class VFilterSelect extends Composite implements Paintable, Field,

popupOpenerClicked = false;

updateRootWidth();
if (!initDone) {
updateRootWidth();
}

initDone = true;
}

/*
* (non-Javadoc)
*
* @see com.google.gwt.user.client.ui.Composite#onAttach()
*/
@Override
protected void onAttach() {
super.onAttach();

/*
* We need to recalculate the root width when the select is attached, so
* #2974 won't happen.
*/
updateRootWidth();
}

/**
* Turns prompting on. When prompting is turned on a command prompt is shown
* in the text box if nothing has been entered.
@@ -1445,13 +1464,33 @@ public class VFilterSelect extends Composite implements Paintable, Field,
* the size of the combobox won't change over time.
*/
int tbWidth = Util.getRequiredWidth(tb);
int openerWidth = Util.getRequiredWidth(popupOpener);

if (popupWidth < 0) {
/*
* Only use the first page popup width so the textbox will not
* get resized whenever the popup is resized.
*/
popupWidth = Util.getRequiredWidth(popupOpener);
}

/*
* Note: iconWidth is here calculated as a negative pixel value so
* you should consider this in further calculations.
*/
int iconWidth = selectedItemIcon.isAttached() ? Util
.measureMarginLeft(tb.getElement())
- Util.measureMarginLeft(selectedItemIcon.getElement()) : 0;

int w = tbWidth + openerWidth + iconWidth;
if ((!initDone || currentPage + 1 <= 0)
int w = tbWidth + popupWidth + iconWidth;

/*
* When the select has a undefined with we need to check that we are
* only setting the text box width relative to the first page width
* of the items. If this is not done the text box width will change
* when the popup is used to view longer items than the text box is
* wide.
*/
if ((!initDone || currentPage + 1 < 0)
&& suggestionPopupMinWidth > w) {
setTextboxWidth(suggestionPopupMinWidth);
w = suggestionPopupMinWidth;

Loading…
Cancel
Save