NativeSelect ignores setWidth (Vaadin 8.0.0)

When setting width of NativeSelect with setWidth, the setting is ignored and the Component is sized automatically to its biggest entry. This causes layout problems, if a NativeSelect has very long entries.

Were there any changes to Vaadin 8 I don’t know or is this a bug?
31203.jpg

There more I look into it, it looks like a bug…

In debugmode it highlights correctly only 270px, which is the value set by setWidth, but it is displayed much wider!
31204.jpg

A simple example using a clean new Vaadin 8 project:

public class MyUI extends UI {

@Override
protected void init(VaadinRequest vaadinRequest) {
    final VerticalLayout layout = new VerticalLayout();
  
    List<String> myList = Arrays.asList("Test 1",
                                        "Test 2",
                                        "Test very long Test very long Test very long Test very long Test very long Test very long ");
    final NativeSelect<String> nsTest = new NativeSelect<>("Test", myList);
    
    nsTest.setWidth("100px");
    
    layout.addComponent(nsTest);
    
    setContent(layout);
}

@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
public static class MyUIServlet extends VaadinServlet {
}

}

Hi Thomas,

Looks like a bug to me too, I was going to suggest opening an issue in github, but noticed you arleady did
#8702
, as a temporary workaround you can use the compatibility com.vaadin.v7.ui.NativeSelect but that requires the
compatibility packages as mentioned in docs
.