the code:
ComboBox<String> comboBox = new ComboBox<>("TEST-Combo");
comboBox.setCaptionAsHtml(true);
comboBox.setItemCaptionGenerator(item -> "<b>" + item + "</b>");
comboBox.setTextInputAllowed(false);
comboBox.setItems("xxx", "<i>yyy</i>", "<b>zzz</b>");
reuslt:
Is it Vaadin Bug or my failure?
EDIT
Vaadin Version 8.5.2
Method
comboBox.setCaptionAsHtml(true)
does not affect items. It sets the mode of the ComboBox caption, which in your case is "TEST-Combo".
There is currently no HTML support for items in ComboBox in Vaadin 8.
However there is comboBox.setStyleGenerator()
which allows you to set item specific styles in CSS. I.e. if you case is to set bold font, you can set something like
comboBox.setStyleGenerator(item -> item.isImportant() ? "bold-font" : "");
and in theme SCSS mixin
.bold-font {
font-weight: bold;
}