SplitPanel rendering issue after component replacement

Hi,

I have a problem with rendering horizontal SplitPanel after replacing one of its components with another component.

I have a SplitPanel (rootSp) that holds a Panel (panel1) and a SplitPanel (secondSp). The secondSp contains two panels (panel2 and panel3). (attached step1.png)

If I do replace the second component of rootSp with panel2, the panel2 is not resized correctly - it does not fill the whole space available. (attached step2.png)

After refreshing the browser (F5) the panel is rendered correctly. (attached step3.png - the desired state)

To reproduce it display following window and press any of the buttons:

public class TestWindow extends Window {
	
	private static int count = 0;
	
	SplitPanel rootSp;
	SplitPanel secondSp;
	
	public TestWindow() {
		rootSp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
		secondSp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
		
		rootSp.setFirstComponent(getSplitPanelContent());
		rootSp.setSecondComponent(secondSp);
		
		secondSp.setFirstComponent(getSplitPanelContent());
		secondSp.setSecondComponent(getSplitPanelContent());
		
		setContent(rootSp);
	}
	
	private Panel getSplitPanelContent() {
		Panel p = new Panel();
		
		Button closePanel3Button = new Button("Close Panel 3");
		closePanel3Button.addListener(new ClickListener() {
			@Override
			public void buttonClick(ClickEvent event) {
				Component panel2 = secondSp.getFirstComponent();
				rootSp.setSecondComponent(panel2);
                                panel2.requestRepaint(); // does not help
			}
		});
		
		p.addComponent(closePanel3Button);
		p.addComponent(new Label("Panel " + count++));
		return p;
	}

}

Is this designed behavior or am I doing something wrong? I would expect the panel2 to occupy the full space right after the button click and not after browser refresh.

I did try to request repaint on the components but that does not work (I think that the reason is that the all the actions are happening on client side strictly - there is no request going to server until the F5 is pressed).

The debug mode and ‘Analyze layout’ does not report any issues.

Thanks for any clues

Igor
11529.png
11530.png
11531.png

This looks like a bug to me, created a ticket
#6149
for it.