Why ListBox does not implement HasSize

I was made aware today that the ListBox component does not implement HasSize and therefore cannot be resized.

  1. Was this on purpose? If so, what are the reasons?

  2. In the [Java examples]
    (https://vaadin.com/components/vaadin-list-box/java-examples) the listboxes seem to be full-width, but not by using width styling. How was this done?

Here’s a recently created ticket about the issue: https://github.com/vaadin/vaadin-list-box-flow/issues/38 which also contains a workaround (extend the component and implement HasSize yourself - you won’t need to implement any methods).

Yes I am aware of the workaround, but in the aforementioned java examples I think this was done differently, because the <vaadin-list-box> element there has no style="width:100%;" attribute (which is there for me when I use the workaround, using listBox.setWidth("100%");.

So I have reason to believe that there already is a way to define width of ListBox somehow. This is what I wanted to ask. Is there a way without the workaround, and if so, how?

There’s only another workaround, which would be accessing the Style object through the Element API (listBox.getElement().getStyle()). There you can add the value "100%" to the width property using the set method.

-Olli

The issue got fixed and merged to master quite fast. Master is now capable of setting sizes, and the methods will be available in the next release. https://github.com/vaadin/vaadin-list-box-flow/issues/38