Skip to content

Moving the component to another parent in one request cycle breaks the client side #46

@stefanuebe

Description

@stefanuebe

Simple scenario: the xterm console is shown in an draggable container. That draggable container is moved to another position, which is internally just a remove from parent A and attach to parent B. This results in an "empty" tag on the client side (it looses basically its xterm instance as it seems).

Removing and adding in two request cycles works, also simply hiding and showing it using setVisible.

The following example shows the issue in a simplified manner:

    public XTermView() {
        XTerm xterm = new XTerm();
        xterm.writeln("Hello world.\n\n");
        xterm.setWidth("500px");
        xterm.setHeight("250px");

        VerticalLayout left = new VerticalLayout(xterm);
        VerticalLayout right = new VerticalLayout();

        add(new Button("Switch", event -> {
            Component parent = xterm.getParent().orElse(null);
            if (parent == left) {
                right.add(xterm);
            } else {
                left.add(xterm);
            }
        }));


        SplitLayout layout = new SplitLayout(left, right);
        layout.setSplitterPosition(50);
        layout.setOrientation(SplitLayout.Orientation.HORIZONTAL);
        add(layout);
    }

The resulting element looks like this after using the Switch button:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Under consideration

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions