diff options
author | Artur Signell <artur@vaadin.com> | 2016-10-10 22:58:04 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-11-11 20:51:21 +0000 |
commit | 3f97add7d89064a734b231de2cffac467a53fcab (patch) | |
tree | 2e887a2637239ac32556713702554d11346231c6 | |
parent | 9726f1581a7722d58494f93d0085535db4772a33 (diff) | |
download | vaadin-framework-3f97add7d89064a734b231de2cffac467a53fcab.tar.gz vaadin-framework-3f97add7d89064a734b231de2cffac467a53fcab.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-- | client/src/main/java/com/vaadin/client/ui/VFilterSelect.java | 3 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java | 12 |
2 files changed, 13 insertions, 2 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VFilterSelect.java b/client/src/main/java/com/vaadin/client/ui/VFilterSelect.java index 2eeff9ece2..38e067658b 100644 --- a/client/src/main/java/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/main/java/com/vaadin/client/ui/VFilterSelect.java @@ -2376,6 +2376,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 9d5d307e10..5cf901a04e 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 |