summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2016-11-29 15:46:06 +0200
committerPekka Hyvönen <pekka@vaadin.com>2016-12-09 09:39:00 +0200
commitd44fa8b3494fb3780d2c3f8ab73a8e202e73ccfd (patch)
tree8097dbd5c26e6179a1fcbd3a14bdcd6c96906756
parent266be8f529c27d6e5f46f2dd15d253584b7ccfbb (diff)
downloadvaadin-framework-d44fa8b3494fb3780d2c3f8ab73a8e202e73ccfd.tar.gz
vaadin-framework-d44fa8b3494fb3780d2c3f8ab73a8e202e73ccfd.zip
Make clicking outside a ComboBox add a pending new item (#18366)
It should not matter how you move from a field to the next. Tabbing to the next field already previously caused the new item handler to be invoked. This fixes the case when you click in the next field to work the same way. Change-Id: I3978d87cde8f05dce92edda2a4a116f4a15e0749
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java3
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java12
2 files changed, 13 insertions, 2 deletions
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java
index 0b7724f3d0..29e4aa006f 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java
@@ -2381,6 +2381,9 @@ public class VFilterSelect extends Composite
focused = false;
if (!readonly) {
+ if (textInputEnabled && allowNewItem) {
+ suggestionPopup.menu.doSelectedItemAction();
+ }
if (selectedOptionKey == null) {
if (explicitSelectedCaption != null) {
setPromptingOff(explicitSelectedCaption);
diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java
index b568ecf912..c16a80856b 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java
@@ -65,6 +65,14 @@ public class ComboBoxSelectingWithNewItemsAllowedTest extends MultiBrowserTest {
}
@Test
+ public void itemIsAddedWhenClickingOutside() {
+ clearInputAndType("foo");
+ findElement(By.tagName("body")).click();
+ assertOneMoreThanInitial();
+ assertThatSelectedValueIs("foo");
+ }
+
+ @Test
public void matchingSuggestionIsSelectedWithEnter() {
typeInputAndHitEnter("a0");
@@ -122,14 +130,14 @@ public class ComboBoxSelectingWithNewItemsAllowedTest extends MultiBrowserTest {
}
@Test
- public void noSelectionAfterMouseOut() {
+ public void selectionOnMouseOut() {
typeInputAndHitEnter("a20");
comboBoxElement.sendKeys(Keys.ARROW_DOWN, Keys.ARROW_DOWN);
findElement(By.className("v-app")).click();
assertInitialItemCount();
- assertThatSelectedValueIs("a20");
+ assertThatSelectedValueIs("a21");
}
@Test