]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixing issue with Vaadin 7 combobox when typing and tabing out fast (#12033)
authorTatu Lund <tatu@vaadin.com>
Wed, 17 Jun 2020 08:11:07 +0000 (11:11 +0300)
committerGitHub <noreply@github.com>
Wed, 17 Jun 2020 08:11:07 +0000 (11:11 +0300)
ComboBox does not select or add a new value (in case allowed) if User enters the value by typing and TABs out fast. This bug was originally reported in https://github.com/vaadin/framework/issues/4276 and fixed by https://dev.vaadin.com/review/#/c/3564/6/client/src/com/vaadin/client/ui/VFilterSelect.java. However later some logic of VFilterSelect was refactored by patch https://github.com/vaadin/framework/commit/acb889336f80227d609b194e56ac6ae3ead0d338, which accidentally removed the fix. In this new PR I am re-applying the missing part of the logic (adopted to the new structure)

Fixes https://github.com/vaadin/framework/issues/6671

client/src/main/java/com/vaadin/client/ui/VFilterSelect.java

index 148157cb844cb31a5ef9dcf3597af8725d592164..f3856389b192f29c5a884ba7c1f4d21b72f6ab7e 100644 (file)
@@ -1553,6 +1553,8 @@ public class VFilterSelect extends Composite
     /** For internal use only. May be removed or replaced in the future. */
     public boolean updateSelectionWhenReponseIsReceived = false;
 
+    private boolean tabPressedWhenPopupOpen = false;
+
     /** For internal use only. May be removed or replaced in the future. */
     public boolean initDone = false;
 
@@ -2200,6 +2202,8 @@ public class VFilterSelect extends Composite
             event.stopPropagation();
             break;
         case KeyCodes.KEY_TAB:
+               tabPressedWhenPopupOpen = true;
+               waitingForFilteringResponse = false;                        
         case KeyCodes.KEY_ENTER:
 
             if (!allowNewItem) {
@@ -2480,6 +2484,15 @@ public class VFilterSelect extends Composite
 
         focused = false;
         if (!readonly) {
+            if (tabPressedWhenPopupOpen) {
+                tabPressedWhenPopupOpen = false;
+                waitingForFilteringResponse = false;
+            } else if ((!suggestionPopup.isAttached() && waitingForFilteringResponse)
+                    || suggestionPopup.isJustClosed()) {
+                // typing so fast the popup was never opened, or it's just
+                // closed
+            waitingForFilteringResponse = false;
+            }
             if (textInputEnabled && allowNewItem) {
                 suggestionPopup.menu.doSelectedItemAction();
             }