diff options
author | Markus Koivisto <markus@vaadin.com> | 2014-04-25 16:58:53 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2014-05-13 13:10:45 +0000 |
commit | aa8761cc6338f48b4fa53025f0c8b02db15b9491 (patch) | |
tree | 9fa40f2f033b9fdec08368cb9247789cbc7bbdb7 /client | |
parent | 81871092d166e126954fdec2106f45e595380137 (diff) | |
download | vaadin-framework-aa8761cc6338f48b4fa53025f0c8b02db15b9491.tar.gz vaadin-framework-aa8761cc6338f48b4fa53025f0c8b02db15b9491.zip |
Force recalc of width when the ComboBox style has changed (#13444)
Change-Id: I7bb500c1b64502881824875e967cf43c5e49a999
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VFilterSelect.java | 16 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java | 24 |
2 files changed, 37 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index 94adc1c4b5..d21d5d2090 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -1924,6 +1924,20 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * For internal use only. May be removed or replaced in the future. */ public void updateRootWidth() { + updateRootWidth(false); + } + + /** + * Calculates the width of the select if the select has undefined width. + * Should be called when the width changes or when the icon changes. + * <p> + * For internal use only. May be removed or replaced in the future. + * + * @param forceUpdate + * a flag that forces a recalculation even if one would not + * normally be done + */ + public void updateRootWidth(boolean forceUpdate) { ComponentConnector paintable = ConnectorMap.get(client).getConnector( this); if (paintable.isUndefinedWidth()) { @@ -1936,7 +1950,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * wide. */ int w = Util.getRequiredWidth(this); - if ((!initDone || currentPage + 1 < 0) + if ((forceUpdate || !initDone || currentPage + 1 < 0) && suggestionPopupMinWidth > w) { /* * We want to compensate for the paddings just to preserve the diff --git a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java index 6c8ccf32a8..84d1475185 100644 --- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java +++ b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java @@ -22,6 +22,7 @@ import java.util.List; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; +import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractFieldConnector; import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.ui.VFilterSelect; @@ -41,6 +42,10 @@ public class ComboBoxConnector extends AbstractFieldConnector implements // update textbox text by a changed item caption. private boolean oldSuggestionTextMatchTheOldSelection; + // Need to recompute the width of the combobox when styles change, see + // #13444 + private boolean stylesChanged; + /* * (non-Javadoc) * @@ -207,8 +212,11 @@ public class ComboBoxConnector extends AbstractFieldConnector implements getWidget().popupOpenerClicked = false; - if (!getWidget().initDone) { - getWidget().updateRootWidth(); + // styles have changed or this is our first time - either way we + // need to recalculate the root width. + if (!getWidget().initDone || stylesChanged) { + boolean forceUpdate = true; + getWidget().updateRootWidth(forceUpdate); } // Focus dependent style names are lost during the update, so we add @@ -217,6 +225,9 @@ public class ComboBoxConnector extends AbstractFieldConnector implements getWidget().addStyleDependentName("focus"); } + // width has been recalculated above, clear style change flag + stylesChanged = false; + getWidget().initDone = true; } @@ -307,4 +318,13 @@ public class ComboBoxConnector extends AbstractFieldConnector implements getWidget().enabled = widgetEnabled; getWidget().tb.setEnabled(widgetEnabled); } + + @Override + public void onStateChanged(StateChangeEvent event) { + super.onStateChanged(event); + if (event.hasPropertyChanged("styles")) { + stylesChanged = true; + } + } + } |