Layouts with only ComboBox always show vertical scroll?

If a panel only has a ComboBox in it with a vertical or horizontal layout, the panel doesn’t seem to quite size itself correctly and there is always a vertical scrollbar.

Panel panel = new Panel();
HorizontalLayout layout = new HorizontalLayout();
layout.addComponent(new ComboBox("foo"));
panel.setContent(layout);
setContent(panel);

Worse yet, if I add a setSizeUndefined() then the panel shrinks too much and now there is a horizontal scrollbar as well! (See attached screenshot)

I can fix all this by adding margins, but I don’t want margins in the panel.

Any ideas? Thanks!

14301.png

Hi Adam,

I cannot reproduce your problem. If I put the given code to a clean project, there is no scrollbars. Do you have some custom css in your project? Which browser did you use?

BR,
Jarno

Thanks for replying Jarno.

Indeed you’re right that there are no scrollbars in Chrome. I created a fresh project just to make sure, and I can confirm that in Firefox there
are
scrollbars. Perhaps I should file a bug report?

Edit: No custom CSS, using whatever default theme (runo?) that Netbeans uses after installing Vaadin plugin (using 7.2)

Thanks for your time
~Adam

Yes, the scrollbars are visible in FireFox. I wasn’t able to reproduce it with other browsers: Safari, Opera and Chrome were also tried. I thinks this is a valid case for a bug report. You can do it
here
.

Btw, what is your use case for undefined sized panels? Usual case for Panels is that you set a defined size to it and expect the scrollbars to appear if the content is larger than the defined size of the panel.

  • Jarno

Thanks, I’ll fill one out.

Perhaps I am not using things correct, I’m pretty new to Vaadin. I have several combo boxes that will be in a row at the top of a webpage. I enclosed them all into a panel so that if the user shrinks their page, scroll bars will appear. Perhaps there’s a better way?

Aah, yes, of course. I have actually used Panel in similar fashion in my projects but not with the ComboBox which seems to cause the issue. One workaround would be to set an explicit height for the panel which should be bigger than the height of the combobox for example panel.setHeight(“50px”).

Ah perfect. That’s a good workaround, thanks for that. I appreciate the help.