diff options
Diffstat (limited to 'server/src/main/java')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java | 6 | ||||
-rw-r--r-- | server/src/main/java/com/vaadin/ui/ComboBox.java | 23 |
2 files changed, 5 insertions, 24 deletions
diff --git a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java index 2b0e6b7d01..f9eed7fef3 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java +++ b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java @@ -230,10 +230,8 @@ public abstract class AbstractSingleSelect<T> extends AbstractListing<T> T oldSelection = getSelectedItem().orElse(getEmptyValue()); doSetSelectedKey(key); - // Update diffstate so that a change will be sent to the client if the - // selection is changed to its original value - updateDiffstate("selectedItemKey", - key == null ? Json.createNull() : Json.create(key)); + // Set diffstate to something that will always send selection to client + updateDiffstate("selectedItemKey", Json.createObject()); fireEvent(new SingleSelectionEvent<>(AbstractSingleSelect.this, oldSelection, true)); diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java index 73d9ad84cf..af100e03f1 100644 --- a/server/src/main/java/com/vaadin/ui/ComboBox.java +++ b/server/src/main/java/com/vaadin/ui/ComboBox.java @@ -25,11 +25,11 @@ import java.util.Objects; import java.util.Set; import java.util.stream.Stream; -import com.vaadin.data.ValueProvider; import org.jsoup.nodes.Element; import com.vaadin.data.HasFilterableDataProvider; import com.vaadin.data.HasValue; +import com.vaadin.data.ValueProvider; import com.vaadin.data.provider.CallbackDataProvider; import com.vaadin.data.provider.DataCommunicator; import com.vaadin.data.provider.DataKeyMapper; @@ -57,7 +57,6 @@ import com.vaadin.ui.declarative.DesignAttributeHandler; import com.vaadin.ui.declarative.DesignContext; import com.vaadin.ui.declarative.DesignFormatter; -import elemental.json.Json; import elemental.json.JsonObject; /** @@ -189,7 +188,8 @@ public class ComboBox<T> extends AbstractSingleSelect<T> public ComboBox() { super(new DataCommunicator<T>() { @Override - protected DataKeyMapper<T> createKeyMapper(ValueProvider<T,Object> identifierGetter) { + protected DataKeyMapper<T> createKeyMapper( + ValueProvider<T, Object> identifierGetter) { return new KeyMapper<T>(identifierGetter) { @Override public void remove(T removeobj) { @@ -831,23 +831,6 @@ public class ComboBox<T> extends AbstractSingleSelect<T> q -> sizeCallback.applyAsInt(q.getFilter().orElse("")))); } - @Override - protected void setSelectedFromClient(String key) { - super.setSelectedFromClient(key); - - /* - * The client side for combo box always expects a state change for - * selectedItemKey after it has sent a selection change. This means that - * we must store a value in the diffstate that guarantees that a new - * value will be sent, regardless of what the value actually is at the - * time when changes are sent. - * - * Keys are always strings (or null), so using a non-string type will - * always trigger a diff mismatch and a resend. - */ - updateDiffstate("selectedItemKey", Json.create(0)); - } - /** * Predicate to check {@link ComboBox} item captions against user typed * strings. |