setWidth using UNITS_EM

I am creating a form with TextFields and ComboBoxes and I want the width of the fields to all be the same. I am defining the widths of the fields using UNITS_EM. However when I run the application the TextFields and ComboBoxes are different lengths. Looking at the styles using firebug, I can see that the .v-filterselect tag for the ComboBox has a defined style width in pixels. I can get their widths to be the same if I use UNITS_PIXELS, however I understand this isn’t following best practices.

Here is my code to reproduce the issue:

public class MyVaadinApplication extends Application
{
    private Window window;

    @Override
    public void init(){
    	setTheme("chameleon"); //same behavior for both chameleon and reindeer.
    	
        window = new Window("My Vaadin Application");
        setMainWindow(window);
        ComboBox box = new ComboBox();
        box.setWidth(13.6f, ComboBox.UNITS_EM);
        
        TextField field = new TextField();
        box.setWidth(13.6f, ComboBox.UNITS_EM);
        
        window.addComponent(box);
        window.addComponent(field);
        
    }
}

I’m using Vaadin 6.8.2, and can reproduce this on Firefox 14.0.1 and Chrome 21.0.1180.83.

I know this is not the place to report bugs, but before I started crying “defect” I wanted to ask, are my expectations on how this should work correct? Should the above code result in both components being the same width?

You are setting the width of the box twice,
and the width of the field never.

greetings
Ralf

Heh… Indeed I am, in this example :grin:

However, upon updating the code to function as I described (rather than what I programmed above) the issue (and my question) is still the same:

public class MyVaadinApplication extends Application
{
    private Window window;

    @Override
    public void init(){
    	setTheme("chameleon"); //same behavior for both chameleon and reindeer.
    	
        window = new Window("My Vaadin Application");
        setMainWindow(window);
        ComboBox box = new ComboBox();
        box.setWidth(13.6f, ComboBox.UNITS_EM);
        
        TextField field = new TextField();
        field.setWidth(13.6f, ComboBox.UNITS_EM);
        
        window.addComponent(box);
        window.addComponent(field);
        
    }
}

Went ahead and created a
ticket
for this.