As the title says, the opened changed listener is directly fired when the MCB is attached to its parent. The event says, that it is closed, so in theory it is not providing false information regarding the state, but the expectation here is, that since the MCB has not been opened yet before, the event itself is simply misfired here.
System.out.println("add");
add(box);
box.addOpenedChangeListener(event -> {
System.out.println("event 3");
});
}
// needed to have the opened change listener available to the outside
public class MultiComboBox1<T> extends MultiComboBox<T> {
@Override
public Registration addOpenedChangeListener(ComponentEventListener<OpenedChangeEvent<MultiComboBox<T>>> listener) {
return super.addOpenedChangeListener(listener);
}
}
Description
As the title says, the opened changed listener is directly fired when the MCB is attached to its parent. The event says, that it is closed, so in theory it is not providing false information regarding the state, but the expectation here is, that since the MCB has not been opened yet before, the event itself is simply misfired here.
Sample to show use case
@Route(value = "multi-combobox-view", layout = MainLayout.class) public class MultiComboboxView extends HorizontalLayout { public MultiComboboxView(SamplePersonService service) { MultiComboBox1 box = new MultiComboBox1<>();
box.addAttachListener(event -> {
System.out.println("on attach");
});
System.out.println("add listener 1");
box.addOpenedChangeListener(event -> {
System.out.println("event 1");
});
System.out.println("set items");
box.setItems(service.list());
System.out.println("add listener 2");
box.addOpenedChangeListener(event -> {
System.out.println("event 2");
});
}