diff options
author | Sun Zhe <31067185+ZheSun88@users.noreply.github.com> | 2019-04-24 13:28:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-24 13:28:01 +0300 |
commit | d3eb272d7be8ef8f2ceca1b9fc85f2adf5c564ea (patch) | |
tree | 67602b4575c52c4c4299d5469e54646f3fabc54b /server | |
parent | e788dae27aaf99f8a6956dcde6eb95f2d1d5c38f (diff) | |
download | vaadin-framework-d3eb272d7be8ef8f2ceca1b9fc85f2adf5c564ea.tar.gz vaadin-framework-d3eb272d7be8ef8f2ceca1b9fc85f2adf5c564ea.zip |
Reset Combobox internal state (#11412)
issue in #11343 and #11385 is not reproducible on top this patch
Three different bugs are involved in this fix:
we bring the old fix(#11094) back and fixed the other related issues:
1) allow adding the same new item after dataProvider got reset, This is cause by the client side parameter `LastNewItemString`, it saves the value added before resetting.
2) clear the pending newItem eagerly, so that the same value will not be added again.
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/ComboBox.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java index a976782ecc..8fadca6c35 100644 --- a/server/src/main/java/com/vaadin/ui/ComboBox.java +++ b/server/src/main/java/com/vaadin/ui/ComboBox.java @@ -191,6 +191,15 @@ public class ComboBox<T> extends AbstractSingleSelect<T> if (getNewItemProvider() != null) { Optional<T> item = getNewItemProvider().apply(itemValue); added = item.isPresent(); + // Fixes issue https://github.com/vaadin/framework/issues/11343 + // Update the internal selection state immediately to avoid + // client side hanging. This is needed for cases that user + // interaction fires multi events (like adding and deleting) + // on a new item during the same round trip. + item.ifPresent(value -> { + setSelectedItem(value, true); + getDataCommunicator().reset(); + }); } else if (getNewItemHandler() != null) { getNewItemHandler().accept(itemValue); // Up to the user to tell if no item was added. @@ -446,7 +455,7 @@ public class ComboBox<T> extends AbstractSingleSelect<T> * @since 8.0 */ public void setDataProvider(CaptionFilter captionFilter, - ListDataProvider<T> listDataProvider) { + ListDataProvider<T> listDataProvider) { Objects.requireNonNull(listDataProvider, "List data provider cannot be null"); @@ -610,12 +619,11 @@ public class ComboBox<T> extends AbstractSingleSelect<T> * <p> * The empty string {@code ""} is the default empty selection caption. * + * @return the empty selection caption, not {@code null} * @see #setEmptySelectionAllowed(boolean) * @see #isEmptySelectionAllowed() * @see #setEmptySelectionCaption(String) * @see #isSelected(Object) - * - * @return the empty selection caption, not {@code null} * @since 8.0 */ public String getEmptySelectionCaption() { |