summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2018-09-26 15:16:40 +0300
committerMehdi Javan <32511762+mehdi-vaadin@users.noreply.github.com>2018-09-26 15:16:40 +0300
commit56ce91c6160a252ddcd952bca6eb7037120ebf59 (patch)
tree2c2172cadf00ffdd391a9b40c980b7335792f37e /server
parente854d6ea83ac38bd0c879a977131c01b6b94b26a (diff)
downloadvaadin-framework-56ce91c6160a252ddcd952bca6eb7037120ebf59.tar.gz
vaadin-framework-56ce91c6160a252ddcd952bca6eb7037120ebf59.zip
Update ComboBox internal state on new item added (#11094)8.6.0.beta1
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/ui/ComboBox.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java
index 0a5a36c856..2d613a90a8 100644
--- a/server/src/main/java/com/vaadin/ui/ComboBox.java
+++ b/server/src/main/java/com/vaadin/ui/ComboBox.java
@@ -186,20 +186,23 @@ public class ComboBox<T> extends AbstractSingleSelect<T>
@Override
public void createNewItem(String itemValue) {
// New option entered
- boolean added = false;
+ boolean clientSideHandling = false;
if (itemValue != null && !itemValue.isEmpty()) {
if (getNewItemProvider() != null) {
- Optional<T> item = getNewItemProvider().apply(itemValue);
- added = item.isPresent();
+ getNewItemProvider().apply(itemValue).ifPresent(value -> {
+ // Update state for the newly selected value
+ setSelectedItem(value, true);
+ getDataCommunicator().reset();
+ });
} else if (getNewItemHandler() != null) {
getNewItemHandler().accept(itemValue);
// Up to the user to tell if no item was added.
- added = true;
+ clientSideHandling = true;
}
}
- if (!added) {
- // New item was not handled.
+ if (!clientSideHandling) {
+ // New item was maybe added with NewItemHandler
getRpcProxy(ComboBoxClientRpc.class).newItemNotAdded(itemValue);
}
}