ComboBox or Select - Set items in BeforeShow() event

When I open a detail view in edit mode, I have to prepare the available options for a ComboBox or Select field.

public void onBeforeShow(BeforeShowEvent event) {
    // Set available options
    field1.setItems(List.of("A", "B", "C"));
}

I found that using setItems(), the field loses the previously entity value and the ComboBox becomes empty. I need to manually save and restore the value.
Is there a better way to do this?
Am I doing something wrong?
Thank you

Hi,

This is the built-in behaviour of Vaadin’s selection components, see flow-components/vaadin-combo-box-flow-parent/vaadin-combo-box-flow/src/main/java/com/vaadin/flow/component/combobox/ComboBoxDataController.java at main · vaadin/flow-components · GitHub

Jmix restores field value if it’s bound to an entity attribute and uses collection container as an items provider, otherwise you need to do it yourself.

Regards,
Gleb