diff options
author | Sun Zhe <31067185+ZheSun88@users.noreply.github.com> | 2018-11-27 14:59:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-27 14:59:17 +0200 |
commit | 8d171648e51d8fcf045643df2d7b431ba8ac9ba0 (patch) | |
tree | e9d9ce01ec7cc58b544c74fffd49a4546eb61bc1 /server | |
parent | 2f72ac663f9eb03028d12324055b54e893fe3cf5 (diff) | |
download | vaadin-framework-8d171648e51d8fcf045643df2d7b431ba8ac9ba0.tar.gz vaadin-framework-8d171648e51d8fcf045643df2d7b431ba8ac9ba0.zip |
Revert "Update ComboBox internal state on new item added (#11094)" (#11331)
* Revert "Update ComboBox internal state on new item added (#11094)"
This reverts commit 56ce91c6160a252ddcd952bca6eb7037120ebf59.
* Add tests to verify the issue
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/ComboBox.java | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java index 2d613a90a8..0a5a36c856 100644 --- a/server/src/main/java/com/vaadin/ui/ComboBox.java +++ b/server/src/main/java/com/vaadin/ui/ComboBox.java @@ -186,23 +186,20 @@ public class ComboBox<T> extends AbstractSingleSelect<T> @Override public void createNewItem(String itemValue) { // New option entered - boolean clientSideHandling = false; + boolean added = false; if (itemValue != null && !itemValue.isEmpty()) { if (getNewItemProvider() != null) { - getNewItemProvider().apply(itemValue).ifPresent(value -> { - // Update state for the newly selected value - setSelectedItem(value, true); - getDataCommunicator().reset(); - }); + Optional<T> item = getNewItemProvider().apply(itemValue); + added = item.isPresent(); } else if (getNewItemHandler() != null) { getNewItemHandler().accept(itemValue); // Up to the user to tell if no item was added. - clientSideHandling = true; + added = true; } } - if (!clientSideHandling) { - // New item was maybe added with NewItemHandler + if (!added) { + // New item was not handled. getRpcProxy(ComboBoxClientRpc.class).newItemNotAdded(itemValue); } } |