Reputation: 56
I want to use the ComboBox component and its feature addCustomValueSetListener. Here is the code I use.
@Route(value="temp", layout = MainLayout::class)
class TempPage: VerticalLayout() {
init {
val combo = ComboBox<String>()
combo.setItems(listOf()) // I get the same behavior with a real list of items
combo.addCustomValueSetListener {
add(Span(it.detail)) // Use the new value
it.source.clear() // Clear the ComboBox to let the user add another custom value
}
add(combo)
}
}
The problem is that when I press Enter after typing a custom value, the combobox is not cleared. In fact, it is cleared but only the first time, afterwards, the clear() method does not work anymore.
Am I missing something ? (I am coding in kotlin, not in java, I don't know if the problem can come from that)
UPDATE:
It seems the problem is known and should be fixed, but I still have the problem
Upvotes: 2
Views: 595
Reputation: 36213
This problem is still not fixed. I've commented on the issue.
If your ComboBox contains String then you can set "" as the value:
combo.setValue("");
But for other objects it seems that setValue(null) only works the first time as you described and you have to use the ugly workaround.
Upvotes: 0