TreeTable freezes when removing / readding disabled parent layout

If you put a treetable into a layout, disable the layout, then remove the layout and then add that layout again, the tree table doesn’t respond to selection / scrolling anymore. If you however click on the expand icon next to an item, everything starts working again.

I compiled a minimal example to demonstrate the issue:

public class BugUI extends UI

    private HorizontalLayout dynamicLayout;
    private VerticalLayout mainLayout;
    private final String COLUMN = "COLUMN";

    public BugUI() {

        TreeTable treeTable = new TreeTable();
        treeTable.addContainerProperty(COLUMN, String.class, null);
        for (int i = 0; i < 100; i++) {


        final CheckBox addedCheckbox = new CheckBox("Added layout");
        addedCheckbox.addValueChangeListener(new Property.ValueChangeListener() {
            public void valueChange(Property.ValueChangeEvent event) {
                if (addedCheckbox.getValue()) {
                } else {

        final CheckBox enabledCheckbox = new CheckBox("Set enabled");
        enabledCheckbox.addValueChangeListener(new Property.ValueChangeListener() {
            public void valueChange(Property.ValueChangeEvent event) {

        dynamicLayout = new HorizontalLayout(treeTable);
        mainLayout = new VerticalLayout(addedCheckbox, enabledCheckbox, dynamicLayout);


    protected void init(VaadinRequest request) {
        getPage().setTitle("Demo UI");


Steps to reproduce:

  1. Try selecting an item in the treetable and scrolling within the table
  2. Click “Set enabled” to disable the treetable’s parent layout
  3. Click “Added layout” to remove the layout containing the treetable
  4. Click “Added layout” to add the layout again
  5. Click “Set enabled”
  6. Try selecting an item and scrolling within the table
  7. To make everything work again, either:
    a) remove and add the layout again when it’s enabled
    b) click on the little icon to expand a row

Anything I’m doing wrong or should I create a bug (although I think this is related to