aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatti Tahvonen <matti@vaadin.com>2017-05-19 11:30:29 +0300
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-07-11 10:01:02 +0300
commitc0227397f5e09a4e7057c65559ee1512936a4f2f (patch)
tree81c71e5f95bc213a04b049d2dfcb0b30b992bdab
parente86dff4c3435dd324c7140363336ad28471c6727 (diff)
downloadvaadin-framework-c0227397f5e09a4e7057c65559ee1512936a4f2f.tar.gz
vaadin-framework-c0227397f5e09a4e7057c65559ee1512936a4f2f.zip
Fix resetting of last filter in VComboBox (#9381)
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
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VComboBox.java1
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingTest.java26
2 files changed, 26 insertions, 1 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VComboBox.java b/client/src/main/java/com/vaadin/client/ui/VComboBox.java
index 668e88b126..2a76907170 100644
--- a/client/src/main/java/com/vaadin/client/ui/VComboBox.java
+++ b/client/src/main/java/com/vaadin/client/ui/VComboBox.java
@@ -2319,7 +2319,6 @@ public class VComboBox extends Composite implements Field, KeyDownHandler,
.findAny().orElse(null);
}
- lastFilter = "";
suggestionPopup.hide();
}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingTest.java
index cf3450a14f..616c9a8e82 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingTest.java
@@ -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;
@@ -28,6 +29,31 @@ public class ComboBoxSelectingTest extends MultiBrowserTest {
}
@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");