diff options
author | Artur Signell <artur.signell@itmill.com> | 2009-09-22 08:36:47 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2009-09-22 08:36:47 +0000 |
commit | da8912fce63a7da163900e83a77991f308873eba (patch) | |
tree | bfac2b1d252d1f018cf5153704fbaf5a97433120 /src/com | |
parent | 524d333b56909ea64e33a59c7a2e61827478b967 (diff) | |
download | vaadin-framework-da8912fce63a7da163900e83a77991f308873eba.tar.gz vaadin-framework-da8912fce63a7da163900e83a77991f308873eba.zip |
Test case and fix for #3268 - ComboBox erroneus input is not always cleared
svn changeset:8879/svn branch:6.1
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java | 17 | ||||
-rw-r--r-- | src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java | 59 |
2 files changed, 68 insertions, 8 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index c0e51d7ec0..998abc157f 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -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 index 0000000000..0d474daa54 --- /dev/null +++ b/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java @@ -0,0 +1,59 @@ +package com.vaadin.tests.components.combobox;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.ComboBox;
+
+public class ComboBoxValueInput extends TestBase {
+
+ @Override
+ protected void setup() {
+ ComboBox cb = new ComboBox("A combobox without input prompt");
+ cb.setImmediate(true);
+ cb.addItem("Value 1");
+ cb.addItem("Value 2");
+ cb.addItem("Value 3");
+
+ addComponent(cb);
+
+ cb = new ComboBox("A combobox with input prompt");
+ cb.setInputPrompt("Please select");
+ cb.setImmediate(true);
+ cb.addItem("Value 1");
+ cb.addItem("Value 2");
+ cb.addItem("Value 3");
+
+ addComponent(cb);
+
+ cb = new ComboBox("A combobox with null item");
+ cb.setInputPrompt("Please select");
+ cb.setImmediate(true);
+ cb.addItem("Null item");
+ cb.addItem("Value 1");
+ cb.addItem("Value 2");
+ cb.addItem("Value 3");
+ cb.setNullSelectionItemId("Null item");
+
+ addComponent(cb);
+
+ cb = new ComboBox("A combobox with null item and input prompt");
+ cb.setImmediate(true);
+ cb.addItem("Null item");
+ cb.addItem("Value 1");
+ cb.addItem("Value 2");
+ cb.addItem("Value 3");
+ cb.setNullSelectionItemId("Null item");
+
+ addComponent(cb);
+ }
+
+ @Override
+ protected String getDescription() {
+ 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";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3268;
+ }
+
+}
|