I have a ComboBox, where as user types the values are loaded from a webservice. If no values are found, I want to reset the combobox to empty value. An example with fixed 2 items without using webservice:
ComboBox comboBox = new ComboBox();
comboBox.addItem("First item");
comboBox.addItem("Second item");
comboBox.setNullSelectionAllowed(true);
comboBox.setInputPrompt("Select an item:");
comboBox.select("First item");
When I tried typing in input prompt “third” and then click away to loose focus, the “First item” stays selected.
When I tried to override this behaviour by manually calling comboBox.select(null) or comboBox.select("") or even comboBox.setValue(null), still the “First item” stays selected.
This sound like a comboBox bug to me, but maybe somebody knows a workaround.
As quick solution you can use this code. Simply add empty element into your combo box and on blur, or what ever action you needed, select it.