From 020fe73bfd861bb8713bfe6e012c483a74dc4074 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Fri, 29 Jul 2016 12:43:57 +0300 Subject: [PATCH] Moved ComboBox suggestion popup width to shared state Change-Id: Ic6da82bc309d90d769e9967feee7fb8a58e9fffc --- .../vaadin/client/ui/combobox/ComboBoxConnector.java | 9 ++------- server/src/main/java/com/vaadin/ui/ComboBox.java | 12 ++---------- .../com/vaadin/shared/ui/combobox/ComboBoxState.java | 7 +++++++ 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java index c0d96fa32a..a5edf00812 100644 --- a/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java @@ -74,6 +74,8 @@ public class ComboBoxConnector extends AbstractFieldConnector implements getWidget().filteringmode = getState().filteringMode; + getWidget().suggestionPopupWidth = getState().suggestionPopupWidth; + Profiler.leave("ComboBoxConnector.onStateChanged update content"); } @@ -99,13 +101,6 @@ public class ComboBoxConnector extends AbstractFieldConnector implements getWidget().currentPage = uidl.getIntVariable("page"); - if (uidl.hasAttribute("suggestionPopupWidth")) { - getWidget().suggestionPopupWidth = uidl - .getStringAttribute("suggestionPopupWidth"); - } else { - getWidget().suggestionPopupWidth = null; - } - getWidget().suggestionPopup.updateStyleNames(getState()); getWidget().allowNewItem = uidl.hasAttribute("allownewitem"); diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java index 9a6cf9f728..274faa505f 100644 --- a/server/src/main/java/com/vaadin/ui/ComboBox.java +++ b/server/src/main/java/com/vaadin/ui/ComboBox.java @@ -162,8 +162,6 @@ public class ComboBox extends AbstractSelect implements */ private boolean scrollToSelectedItem = true; - private String suggestionPopupWidth = null; - /** * If text input is not allowed, the ComboBox behaves like a pretty * NativeSelect - the user can not enter any text and clicking the text @@ -279,11 +277,6 @@ public class ComboBox extends AbstractSelect implements String[] selectedKeys = new String[(getValue() == null && getNullSelectionItemId() == null ? 0 : 1)]; - if (suggestionPopupWidth != null) { - target.addAttribute("suggestionPopupWidth", - suggestionPopupWidth); - } - // Paints the options and create array of selected id keys int keyIndex = 0; @@ -887,7 +880,7 @@ public class ComboBox extends AbstractSelect implements * @since 7.7 */ public String getPopupWidth() { - return suggestionPopupWidth; + return getState(false).suggestionPopupWidth; } /** @@ -912,8 +905,7 @@ public class ComboBox extends AbstractSelect implements * the width */ public void setPopupWidth(String width) { - suggestionPopupWidth = width; - markAsDirty(); + getState().suggestionPopupWidth = width; } /** diff --git a/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java b/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java index 6eae3fc46e..95e624779a 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java @@ -55,4 +55,11 @@ public class ComboBoxState extends AbstractSelectState { */ public FilteringMode filteringMode = FilteringMode.STARTSWITH; + /** + * Suggestion pop-up's width as a CSS string. By using relative units (e.g. + * "50%") it's possible to set the popup's width relative to the ComboBox + * itself. + */ + public String suggestionPopupWidth = null; + } -- 2.39.5