]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix resetting of last filter in VComboBox (#9381)
authorMatti Tahvonen <matti@vaadin.com>
Fri, 19 May 2017 08:30:29 +0000 (11:30 +0300)
committerAleksi Hietanen <aleksi@vaadin.com>
Fri, 19 May 2017 08:30:29 +0000 (11:30 +0300)
Currently the reset method resets the lastFilter as well and then the logic thinks items don’t need to be refreshed when popup is reopened.

Fixes #9027
Fixes #7790

client/src/main/java/com/vaadin/client/ui/VComboBox.java
uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingTest.java

index 668e88b126c236a20c91a70e150d7449dfa6153a..2a76907170b5d3bb54b235dbf1291ae4843eda8b 100644 (file)
@@ -2319,7 +2319,6 @@ public class VComboBox extends Composite implements Field, KeyDownHandler,
                     .findAny().orElse(null);
         }
 
-        lastFilter = "";
         suggestionPopup.hide();
     }
 
index cf3450a14f5dd7594b4493315847aa44c6cdfe86..616c9a8e8271099838971f084c14d664f1cdc91c 100644 (file)
@@ -3,6 +3,7 @@ package com.vaadin.tests.components.combobox;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
+import org.junit.Assert;
 import org.junit.Test;
 import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
@@ -27,6 +28,31 @@ public class ComboBoxSelectingTest extends MultiBrowserTest {
         comboBoxElement = $(ComboBoxElement.class).first();
     }
 
+    @Test
+    public void ensureOldFilterIsCleared() {
+        comboBoxElement.openPopup();
+        int initialVisibleOptions = countVisibleOptions();
+        clearInputAndType("b11");
+        int visibleOptionsAfterFiltering = countVisibleOptions();
+        Assert.assertEquals(1, visibleOptionsAfterFiltering);
+        clickOnLabel();
+        sleep(1000);
+        // no selection was made, clicking on arrow should show all options
+        // again
+        comboBoxElement.openPopup();
+
+        int visibleOptions = countVisibleOptions();
+        Assert.assertEquals(initialVisibleOptions, visibleOptions);
+    }
+
+    private int countVisibleOptions() {
+        return comboBoxElement.getPopupSuggestions().size();
+    }
+
+    private void clickOnLabel() {
+        getDriver().findElement(By.cssSelector(".v-label")).click();
+    }
+
     @Test
     public void firstSuggestionIsSelectedWithEnter() {
         typeInputAndHitEnter("a");