Quellcode durchsuchen

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
tags/7.7.4
Artur Signell vor 7 Jahren
Ursprung
Commit
3f97add7d8

+ 3
- 0
client/src/main/java/com/vaadin/client/ui/VFilterSelect.java Datei anzeigen

@@ -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);

+ 10
- 2
uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java Datei anzeigen

@@ -64,6 +64,14 @@ public class ComboBoxSelectingWithNewItemsAllowedTest extends MultiBrowserTest {
assertThatSelectedValueIs("a");
}

@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

Laden…
Abbrechen
Speichern