diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2018-09-26 15:16:40 +0300 |
---|---|---|
committer | Mehdi Javan <32511762+mehdi-vaadin@users.noreply.github.com> | 2018-09-26 15:16:40 +0300 |
commit | 56ce91c6160a252ddcd952bca6eb7037120ebf59 (patch) | |
tree | 2c2172cadf00ffdd391a9b40c980b7335792f37e /client | |
parent | e854d6ea83ac38bd0c879a977131c01b6b94b26a (diff) | |
download | vaadin-framework-56ce91c6160a252ddcd952bca6eb7037120ebf59.tar.gz vaadin-framework-56ce91c6160a252ddcd952bca6eb7037120ebf59.zip |
Update ComboBox internal state on new item added (#11094)8.6.0.beta1
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/VComboBox.java | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VComboBox.java b/client/src/main/java/com/vaadin/client/ui/VComboBox.java index f80927ec1d..2575f056b9 100644 --- a/client/src/main/java/com/vaadin/client/ui/VComboBox.java +++ b/client/src/main/java/com/vaadin/client/ui/VComboBox.java @@ -16,16 +16,6 @@ package com.vaadin.client.ui; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Set; -import java.util.UUID; -import java.util.logging.Logger; - import com.google.gwt.animation.client.AnimationScheduler; import com.google.gwt.aria.client.Roles; import com.google.gwt.core.client.JavaScriptObject; @@ -85,6 +75,15 @@ import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.util.SharedUtil; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Set; +import java.util.logging.Logger; + /** * Client side implementation of the ComboBox component. * @@ -258,12 +257,12 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, return $entry(function(e) { var deltaX = e.deltaX ? e.deltaX : -0.5*e.wheelDeltaX; var deltaY = e.deltaY ? e.deltaY : -0.5*e.wheelDeltaY; - + // IE8 has only delta y if (isNaN(deltaY)) { deltaY = -0.5*e.wheelDelta; } - + @com.vaadin.client.ui.VComboBox.JsniUtil::moveScrollFromEvent(*)(widget, deltaX, deltaY, e, e.deltaMode); }); }-*/; @@ -1636,6 +1635,11 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, performSelection(selectedKey, oldSuggestionTextMatchTheOldSelection, !isWaitingForFilteringResponse() || popupOpenerClicked); + // currentSuggestion should be set to match the value of the + // ComboBox, especially when a new item is added. + resetCurrentSuggestionIfNecessary(selectedKey, selectedCaption, + selectedIconUri); + cancelPendingPostFiltering(); setSelectedCaption(selectedCaption); @@ -1643,6 +1647,16 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, setSelectedItemIcon(selectedIconUri); } + private void resetCurrentSuggestionIfNecessary(String selectedKey, + String selectedCaption, String selectedIconUri) { + if (currentSuggestion == null + && (selectedKey != null || selectedCaption != null)) + currentSuggestion = new ComboBoxSuggestion(selectedKey, + selectedCaption, "", selectedIconUri); + else if (selectedKey == null && selectedCaption == null) + currentSuggestion = null; + } + } // TODO decide whether this should change - affects themes and v7 @@ -2110,6 +2124,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, currentSuggestion = null; // #13217 selectedOptionKey = null; setText(getEmptySelectionCaption()); + return; } // some item selected for (ComboBoxSuggestion suggestion : currentSuggestions) { |