Search code examples
javavaadinvaadin-elements

Vaadin ComboBox don't allow me to click


I'm using Vaadin ComboBox in my Project and now I've got a new problem, which don't allows me to open the Combo's list after clicking on the ComboBox or on the DropDown Icon! I can type in the ComboBox and with arrow keys from the keyboard I can open the ComboBox list but not with clicking. I found out, when I hold my mouse pointer in a specific area top on the ComboBox, the pointer will change to a Hand and then I can open the list with clicking but just in that case and it happends rare that i can focus the mouse pointer on that area, it's like a small dot on the whole ComboBox.

And the Only code I am using for this ComboBox is, EDITED:

public class ChildElement extends OgsAbstractForm<Child> {

    @Inject
    ChildFacade childFacade;

    ComboBox cbChild=new ComboBox();
    HorizontalLayout mainLayout=new MHorizontalLayout();

@Override
protected Component createContent() {

    List<Child> children=new ArrayList<Child>();
    children.addAll(childFacade.findAll());

    for(int i=0;i<children.size();i++){
        cbChild.addItem(children.get(i).getName());
    }

    cbChild.select(children.get(0).getName());

    cbChild.setFilteringMode(FilteringMode.CONTAINS);


    mainLayout.addComponent(cbChild);
    return mainLayout;
}

}

And then I'm using this element in a View like below,

public class OGSVertragView extends CssLayout implements View{

@Inject
ChildElement childElement;

VerticalLayout main=new VerticalLayout();

@PostConstruct
void init() {

    main.addComponent(childElement);

    addComponents(main);

}
}

It would be really nice, when someone could somehow give me a clue or helps me.

Best Regards!


Solution

  • Looks for me like your ComboBox doesn't have enough space. Try setting mainLayoutheight like 200-300 px, and make sure your VerticalLayout main will give enough space to `mainLayout. Also try adding:

    cbChild.setImmediate(true);
    

    + Small tip about initializing variables