From 901705e1c8ef4253cccef07999f79ffdc5e2bcd4 Mon Sep 17 00:00:00 2001 From: Olli Tietäväinen Date: Fri, 12 Jul 2019 10:44:55 +0300 Subject: 11642 refresh pagelength 0 combobox items after dataprovider update (#11653) * Fixes #11642. ComboBox with pageLength 0 should be updated if DataProvider changes * added comments, fixed imports --- .../vaadin/client/ui/combobox/ComboBoxConnector.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'client/src') diff --git a/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java index 2ef091569d..2709175c5c 100644 --- a/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java @@ -62,6 +62,12 @@ public class ComboBoxConnector extends AbstractListingConnector */ private String pendingNewItemValue = null; + /** + * If this flag is toggled, even unpaged data sources should be updated on + * reset. + */ + private boolean forceDataSourceUpdate = false; + @Override protected void init() { super.init(); @@ -123,6 +129,11 @@ public class ComboBoxConnector extends AbstractListingConnector getWidget().setEmptySelectionCaption(getState().emptySelectionCaption); } + @OnStateChange("forceDataSourceUpdate") + private void onForceDataSourceUpdate() { + forceDataSourceUpdate = getState().forceDataSourceUpdate; + } + @OnStateChange({ "selectedItemKey", "selectedItemCaption", "selectedItemIcon" }) private void onSelectionChange() { @@ -503,9 +514,13 @@ public class ComboBoxConnector extends AbstractListingConnector @Override public void resetDataAndSize(int estimatedNewDataSize) { if (getState().pageLength == 0) { - if (getWidget().suggestionPopup.isShowing()) { + if (getWidget().suggestionPopup.isShowing() + || forceDataSourceUpdate) { dataSource.ensureAvailability(0, estimatedNewDataSize); } + if (forceDataSourceUpdate) { + rpc.resetForceDataSourceUpdate(); + } // else lets just wait till the popup is opened before // everything is fetched to it. this could be optimized later on // to fetch everything if in-memory data is used. -- cgit v1.2.3