]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test case and fix for #3268 - ComboBox erroneus input is not always cleared
authorArtur Signell <artur.signell@itmill.com>
Tue, 22 Sep 2009 08:36:47 +0000 (08:36 +0000)
committerArtur Signell <artur.signell@itmill.com>
Tue, 22 Sep 2009 08:36:47 +0000 (08:36 +0000)
svn changeset:8879/svn branch:6.1

src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java [new file with mode: 0644]

index c0e51d7ec063628f07e9383f6018dfb6d9281df5..998abc157f996c039ae83849177ef21d91c90a03 100644 (file)
@@ -490,16 +490,17 @@ public class VFilterSelect extends Composite implements Paintable, Field,
                             lastFilter.toLowerCase())) {
                 doItemAction(item, true);
             } else {
-                if (currentSuggestion != null) {
+                // currentSuggestion has key="" for nullselection
+                if (currentSuggestion != null
+                        && !currentSuggestion.key.equals("")) {
+                    // An item (not null) selected
                     String text = currentSuggestion.getReplacementString();
-                    /*
-                     * TODO? if (text.equals("")) {
-                     * addStyleDependentName(CLASSNAME_PROMPT);
-                     * tb.setText(inputPrompt); prompting = true; } else {
-                     * tb.setText(text); prompting = false;
-                     * removeStyleDependentName(CLASSNAME_PROMPT); }
-                     */
+                    tb.setText(text);
                     selectedOptionKey = currentSuggestion.key;
+                } else {
+                    // Null selected
+                    tb.setText("");
+                    selectedOptionKey = null;
                 }
             }
             suggestionPopup.hide();
diff --git a/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java b/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java
new file mode 100644 (file)
index 0000000..0d474da
--- /dev/null
@@ -0,0 +1,59 @@
+package com.vaadin.tests.components.combobox;\r
+\r
+import com.vaadin.tests.components.TestBase;\r
+import com.vaadin.ui.ComboBox;\r
+\r
+public class ComboBoxValueInput extends TestBase {\r
+\r
+    @Override\r
+    protected void setup() {\r
+        ComboBox cb = new ComboBox("A combobox without input prompt");\r
+        cb.setImmediate(true);\r
+        cb.addItem("Value 1");\r
+        cb.addItem("Value 2");\r
+        cb.addItem("Value 3");\r
+\r
+        addComponent(cb);\r
+\r
+        cb = new ComboBox("A combobox with input prompt");\r
+        cb.setInputPrompt("Please select");\r
+        cb.setImmediate(true);\r
+        cb.addItem("Value 1");\r
+        cb.addItem("Value 2");\r
+        cb.addItem("Value 3");\r
+\r
+        addComponent(cb);\r
+\r
+        cb = new ComboBox("A combobox with null item");\r
+        cb.setInputPrompt("Please select");\r
+        cb.setImmediate(true);\r
+        cb.addItem("Null item");\r
+        cb.addItem("Value 1");\r
+        cb.addItem("Value 2");\r
+        cb.addItem("Value 3");\r
+        cb.setNullSelectionItemId("Null item");\r
+\r
+        addComponent(cb);\r
+\r
+        cb = new ComboBox("A combobox with null item and input prompt");\r
+        cb.setImmediate(true);\r
+        cb.addItem("Null item");\r
+        cb.addItem("Value 1");\r
+        cb.addItem("Value 2");\r
+        cb.addItem("Value 3");\r
+        cb.setNullSelectionItemId("Null item");\r
+\r
+        addComponent(cb);\r
+    }\r
+\r
+    @Override\r
+    protected String getDescription() {\r
+        return "A combobox should always show the selected value when it is not focused. Entering a text when nothing is selected and blurring the combobox should reset the value. The same should happen when a value is selected";\r
+    }\r
+\r
+    @Override\r
+    protected Integer getTicketNumber() {\r
+        return 3268;\r
+    }\r
+\r
+}\r