Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composite with VerticalLayout root breaks layouting #12153

Closed
tepi opened this issue Nov 27, 2020 · 1 comment · Fixed by #12154
Closed

Composite with VerticalLayout root breaks layouting #12153

tepi opened this issue Nov 27, 2020 · 1 comment · Fixed by #12154

Comments

@tepi
Copy link
Contributor

tepi commented Nov 27, 2020

Tested on Vaadin 8.11.3 and MacOS Chrome Version 87.0.4280.67 (Official Build) (x86_64). Also occurs in Firefox, so does not seem to be browser-dependent.

Problem: LayoutManager does not seem to properly recalculate sizes for various components which are in a Composite that has a VerticalLayout as its root. So in the first example the connector hierarchy is Composite->VerticalLayout->Grid.

public class MyUI extends UI {

	@Override
	protected void init(VaadinRequest vaadinRequest) {
		CompositeGrid vsp = new CompositeGrid();
		setContent(vsp);
	}

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

	private Component buildGrid() {
		Grid<Person> grid = new Grid<Person>(Person.class);
		grid.setSizeFull();
		List<Person> persons = new ArrayList<>();
		for (int i = 0; i < 100; i++) {
			persons.add(new Person("Firstname" + i, "Lastname" + i));
		}
		grid.setItems(persons);
		return grid;
	}

	public class CompositeGrid extends Composite {
		public CompositeGrid() {
			VerticalLayout root = new VerticalLayout();
			root.setMargin(false);
			root.addComponentsAndExpand(buildGrid());
			setCompositionRoot(root);
			setSizeFull();
		}
	}
}

This does not seem to depend on Grid, also happen on SplitPanel in same kind of hierarchy:

public class MyUI extends UI {

	@Override
	protected void init(VaadinRequest vaadinRequest) {
		CompositeVSP vsp = new CompositeVSP();
		setContent(vsp);

		CompositeHSP hsp = new CompositeHSP();
		hsp.setSizeFull();
		vsp.set2(hsp);
	}

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

	public class CompositeVSP extends Composite {

		private VerticalSplitPanel verticalSplitPanel;

		public CompositeVSP() {
			verticalSplitPanel = new VerticalSplitPanel();

			VerticalLayout root = new VerticalLayout();
			root.setMargin(false);
			root.addComponentsAndExpand(verticalSplitPanel);
			setCompositionRoot(root);
			setSizeFull();
		}

		public void set1(Component c) {
			verticalSplitPanel.setFirstComponent(c);
		}

		public void set2(Component c) {
			verticalSplitPanel.setSecondComponent(c);
		}
	}

	public class CompositeHSP extends Composite {

		private HorizontalSplitPanel horizontalSplitPanel;

		public CompositeHSP() {
			horizontalSplitPanel = new HorizontalSplitPanel();
			VerticalLayout root = new VerticalLayout();
			root.setMargin(false);
			root.addComponentsAndExpand(horizontalSplitPanel);
			setCompositionRoot(root);
			setSizeFull();
		}

		public void set1(Component c) {
			horizontalSplitPanel.setFirstComponent(c);
		}

		public void set2(Component c) {
			horizontalSplitPanel.setSecondComponent(c);
		}
	}
}

So to me it looks like when you have a Composite with a VerticalLayout as its root, any ManagedLayout implementors in that VerticalLayout fail to resize when they should.

@tepi
Copy link
Contributor Author

tepi commented Nov 27, 2020

Video of behavior: https://gofile.io/d/vK8TOH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant