Skip to content

Appending a grid as virtual child throws client side exceptions #2555

Closed

Description

@knoobie

Description of the bug

Appending a grid as virtual child throws exception on client side.

image

Expected behavior

No exception is thrown.

Minimal reproducible example

Copy paste the following in any view:

    Grid<String> grid = new Grid<>();
    grid.addColumn(s -> s).setHeader("Test");
    grid.setWidth("200px");
    grid.setHeight("300px");
    grid.setItems("1", "2", "3");

    Html html = new Html("<div class=\"bg-base\"><div data-child=\"grid\"></div></div>");
    html.getElement().appendVirtualChild(grid.getElement());
    html.getElement().executeJs("this.querySelector('[data-child=\"'+$0+'\"]').appendChild($1)", "grid", grid.getElement());
    grid.addDetachListener((detachEvent) -> {
      detachEvent.unregisterListener();
      html.getElement().executeJs("this.querySelector && this.querySelector('[data-child=\"'+$0+'\"]').lastChild.remove()", "grid");
    });
    add(html);

Versions

  • Vaadin: 23.0.0.alpha2
  • Java version: 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions