Skip to content

Commit

Permalink
Make clicking outside a ComboBox add a pending new item (#18366)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ahie authored and pleku committed Dec 9, 2016
1 parent 266be8f commit d44fa8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -2381,6 +2381,9 @@ public void onBlur(BlurEvent event) {

focused = false;
if (!readonly) {
if (textInputEnabled && allowNewItem) {
suggestionPopup.menu.doSelectedItemAction();
}
if (selectedOptionKey == null) {
if (explicitSelectedCaption != null) {
setPromptingOff(explicitSelectedCaption);
Expand Down
Expand Up @@ -64,6 +64,14 @@ public void itemIsAddedWithTab() {
assertThatSelectedValueIs("a");
}

@Test
public void itemIsAddedWhenClickingOutside() {
clearInputAndType("foo");
findElement(By.tagName("body")).click();
assertOneMoreThanInitial();
assertThatSelectedValueIs("foo");
}

@Test
public void matchingSuggestionIsSelectedWithEnter() {
typeInputAndHitEnter("a0");
Expand Down Expand Up @@ -122,14 +130,14 @@ public void selectionRemainsAfterOpeningPopup() {
}

@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
Expand Down

0 comments on commit d44fa8b

Please sign in to comment.