]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixed #8321: adding/removing items in a ComboBox FocusListener breaks the dropdown...
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>
Thu, 2 Feb 2012 15:30:15 +0000 (15:30 +0000)
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>
Thu, 2 Feb 2012 15:30:15 +0000 (15:30 +0000)
Clicking the dropdown button on an unfocused ComboBox would send a separate options request and a focus event request. The responses would confuse the rendering logic. The changes are now sent in a single variable burst.

svn changeset:22863/svn branch:6.7

src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java

index 9a6cbdcd9b81e65ebfdd5b87a3edd5ca38f81ade..e261286cb7f7adaa3f91ee2c0585b6817eced200 100644 (file)
@@ -1013,6 +1013,20 @@ public class VFilterSelect extends Composite implements Paintable, Field,
      *            The filter to apply to the components
      */
     public void filterOptions(int page, String filter) {
+        filterOptions(page, filter, true);
+    }
+
+    /**
+     * Filters the options at certain page using the given filter
+     * 
+     * @param page
+     *            The page to filter
+     * @param filter
+     *            The filter to apply to the options
+     * @param immediate
+     *            Whether to send the options request immediately
+     */
+    private void filterOptions(int page, String filter, boolean immediate) {
         if (filter.equals(lastFilter) && currentPage == page) {
             if (!suggestionPopup.isAttached()) {
                 suggestionPopup.showSuggestions(currentSuggestions,
@@ -1032,7 +1046,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
 
         waitingForFilteringResponse = true;
         client.updateVariable(paintableId, "filter", filter, false);
-        client.updateVariable(paintableId, "page", page, true);
+        client.updateVariable(paintableId, "page", page, immediate);
         lastFilter = filter;
         currentPage = page;
     }
@@ -1622,7 +1636,12 @@ public class VFilterSelect extends Composite implements Paintable, Field,
             // ask suggestionPopup if it was just closed, we are using GWT
             // Popup's auto close feature
             if (!suggestionPopup.isJustClosed()) {
-                filterOptions(-1, "");
+                // If a focus event is not going to be sent, send the options
+                // request immediately; otherwise queue in the same burst as the
+                // focus event. Fixes #8321.
+                boolean immediate = focused
+                        || !client.hasEventListeners(this, EventId.FOCUS);
+                filterOptions(-1, "", immediate);
                 popupOpenerClicked = true;
                 lastFilter = "";
             }