]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix ComboBox issue with font-based item icons (#14660)
authorTeemu Pòˆntelin <teemu@vaadin.com>
Wed, 24 Sep 2014 19:48:55 +0000 (22:48 +0300)
committerVaadin Code Review <review@vaadin.com>
Mon, 29 Sep 2014 12:44:27 +0000 (12:44 +0000)
Change-Id: I8f3de9556cc62670c28523886998f89383b76305

client/src/com/vaadin/client/ui/VFilterSelect.java
uitest/src/com/vaadin/tests/fonticon/FontIconsTest.java

index 356e7291c4ca7b6684dff0e4f0afb94264b48e8c..8e72d1ce52f1b9eea41bae1e074912edb86f3f20 100644 (file)
@@ -446,16 +446,13 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
         private void selectItem(final MenuItem newSelectedItem) {
             menu.selectItem(newSelectedItem);
 
-            String text = newSelectedItem != null ? newSelectedItem.getText()
-                    : "";
-
             // Set the icon.
             FilterSelectSuggestion suggestion = (FilterSelectSuggestion) newSelectedItem
                     .getCommand();
             setSelectedItemIcon(suggestion.getIconUri());
 
             // Set the text.
-            setText(text);
+            setText(suggestion.getReplacementString());
 
             menu.updateKeyboardSelectedItem();
         }
index 61a38bf552dae5e571a012ed42d7d33371637182..948c3c13b2640984ec31c6bc054775e8beb6e827 100644 (file)
  */
 package com.vaadin.tests.fonticon;
 
+import static org.junit.Assert.assertEquals;
+
 import java.io.IOException;
 
 import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebElement;
 
 import com.vaadin.tests.tb3.MultiBrowserTest;
 
@@ -28,4 +33,33 @@ public class FontIconsTest extends MultiBrowserTest {
         openTestURL();
         compareScreen("all");
     }
+
+    @Test
+    public void comboBoxItemIconsOnKeyboardNavigation() throws Exception {
+        openTestURL();
+        WebElement comboBoxInput = getDriver().findElement(
+                By.className("v-filterselect-input"));
+
+        // No initial value.
+        assertEquals("", comboBoxInput.getText());
+
+        // Navigate to the first item with keyboard navigation.
+        sendKeys(comboBoxInput, Keys.ARROW_DOWN, Keys.ARROW_DOWN,
+                Keys.ARROW_DOWN);
+
+        // Value must be "One" without any extra characters.
+        // See ticket #14660
+        assertEquals("One", comboBoxInput.getAttribute("value"));
+
+        // Check also the second item.
+        sendKeys(comboBoxInput, Keys.ARROW_DOWN);
+        assertEquals("Two", comboBoxInput.getAttribute("value"));
+    }
+
+    private void sendKeys(WebElement element, Keys... keys) throws Exception {
+        for (Keys key : keys) {
+            element.sendKeys(key);
+            sleep(10); // For PhantomJS.
+        }
+    }
 }