Scrollable layout in Vaadin 8

Sometimes I get it to work, other times not so much, and I can’t seem to figure out the factors at play.
Answers to these two questions would resolve the issue:

  1. Is there a snippet of a scrollable VerticalLayout implementation?
    This is the code I’m using which works sometimes and other times it compresses the items to fit the vertical space without adding a scroll bar.
  protected void init(VaadinRequest vaadinRequest) {
        final VerticalLayout layout = new VerticalLayout();
        setContent(layout);
		layout.setHeight("100%");
		VerticalLayout thisshouldnotscroll=new VerticalLayout(); thisshouldnotscroll.setHeight("100%");
		thisshouldnotscroll.addComponent(new Label("This should not scroll"));
		VerticalLayout thisshouldscroll=new VerticalLayout();
		thisshouldscroll.setHeight("100%");
		for (int i=0;i<200;i++){thisshouldscroll.addCompoenent(new Label("Item in list"));}
		layout.addComponents(thisshouldnotscroll,thisshouldscroll);
  1. How to you switch from flex to block mode in Vaadin 8?

Hi Andrei

In Vaadin 8, there is a Panel component which is basically a scrollable VerticalLayout. Have you tried this out yet?
https://vaadin.com/docs/v8/framework/layout/layout-panel.html

If you wanted to implement your own version of a scrollable layout, then you will have to nest 2 layouts. The outer will have a fix height i.e. 100% while the inner can expand to any size it needs. then you set overflow of the outer to hidden. I made a ScrollableVerticalLayout for Vaadin Flow, and although you can’t use it directly because it’s not Vaadin 8 compatible, you can see how I did it in my [github]
(https://github.com/KasparScherrer/vaadin-scrollable-layouts/blob/master/src/main/java/ch/carnet/kasparscherrer/VerticalScrollLayout.java) and replicate it in your project