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++) {
            treeTable.addItem(UUID.randomUUID()).getItemProperty(COLUMN).setValue(UUID.randomUUID().toString());
        }

        treeTable.setSelectable(true);
        treeTable.setHeight("100px");

        final CheckBox addedCheckbox = new CheckBox("Added layout");
        addedCheckbox.setValue(true);
        addedCheckbox.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                if (addedCheckbox.getValue()) {
                    mainLayout.addComponent(dynamicLayout);
                } else {
                    mainLayout.removeComponent(dynamicLayout);
                }
            }
        });


        final CheckBox enabledCheckbox = new CheckBox("Set enabled");
        enabledCheckbox.setValue(true);
        enabledCheckbox.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                dynamicLayout.setEnabled(enabledCheckbox.getValue());
            }
        });
        addedCheckbox.setImmediate(true);
        enabledCheckbox.setImmediate(true);

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

        setContent(mainLayout);
    }

    @Override
    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 http://dev.vaadin.com/ticket/11321)?

Thanks!