aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Alhroos <john.ahlroos@itmill.com>2010-06-29 10:46:25 +0000
committerJohn Alhroos <john.ahlroos@itmill.com>2010-06-29 10:46:25 +0000
commit2056d9d9552497a22d3c648ada50b915c32be71d (patch)
treeb1b1f47a77cfd8ede0d20b83717f05d8b3f604d1
parentf0769a38c260cbe1b378aecf0e9059b39ac48867 (diff)
downloadvaadin-framework-2056d9d9552497a22d3c648ada50b915c32be71d.tar.gz
vaadin-framework-2056d9d9552497a22d3c648ada50b915c32be71d.zip
Fix for #2974
svn changeset:13959/svn branch:6.4
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
index bcda91266c..ed9acb6684 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
@@ -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;