Strange behavior of ComboBox in Form

Hi,

I’m using ComboBox in a Form which takes BeanItem as ItemDataSource. My FormFieldFactorys relevant part looks like this:


if(propertyId.equals("projectManager")) {
			this.managerSelect = new ComboBox("Manager");
			managerSelect.addListener(this);
			managerSelect.setImmediate(true);
			managerSelect.setNullSelectionAllowed(false);
			managerSelect.setNewItemsAllowed(false);
			
			for(User u : managers) {
				managerSelect.addItem(u);
				managerSelect.setItemCaption(u, u.getName());
			}
			
			return managerSelect;
		}

Now my problem is that if I set forms readOnly to true (like it is not editable, really just read only) and then press edit (only change its footer and set readOnly to false), then press cancel (changes readOnly to true) and repreat this, then everytime I press edit so my form becames editable, the width of the ComboBox grows something like 5mm.

And this happens every time!! What am I doing wrong?

Here’s also my setProjectEditable method which is called with parameter true when I click edit and with false when I click cancel.


public void setProjectEditable(boolean editable) {
		getEditForm().setReadOnly(!editable);
		if(!editable){
			getEditForm().setFooter(taskFooter);
		}
		else{
			getEditForm().setFooter(getFooter());
		}
	}

Thanks for any help!!

This sounds like a bug, but I could not reproduce it with simply setting a combo box as read only and back.

Which Vaadin version are you using?
What is the size of the form and its layout? In what kind of a layout is it?

You could also check that all your layouts in that view are valid using the ?debug parameter in the application url and then clicking “Analyze layouts”.

If your layouts are valid, a small program that demonstrates the issue would be very helpful. You could also create a new
ticket
about the issue.

Thanks for your answer Henri!!

I made a dummy test project to illustrate the problem. By repeatedly pressing Edit and Cancel (which in fact do the opposite of what they should do) the width of ComboBox grows all the time.

I didn’t create a ticket about it yet because I guess that it might as well be my mistake on something. -_-
11461.zip (3.57 MB)

Your example had an invalid layout (check “Analyze layouts” with the URL parameter ?debug), but that was not behind the problem.

There seems to be a bug in Vaadin - created
ticket 5833
with a reduced test case.