Hello to all,
I’m observing a strange behaviour regarding the onDetach method (I’m using vaadin 10.0.4).
I have a simple RouterLayout with a RouterLink.
@Route("")
public class MainLayout extends Div implements RouterLayout {
public MainLayout() {
add(new RouterLink("Test View", TestView.class));
}
@Override
protected void onDetach(DetachEvent detachEvent) {
System.out.println("calling onDetach method for component " + this);
}
}
@Route(value = "view", layout = MainLayout.class)
public class TestView extends Div {
public TestView() {
add(new TestComponent());
}
@Override
protected void onDetach(DetachEvent detachEvent) {
System.out.println("calling onDetach method for component " + this);
}
}
public class TestComponent extends Div {
@Override
protected void onDetach(DetachEvent detachEvent) {
System.out.println("calling onDetach method for component " + this);
}
}
When I navigate using the link, the onDetach method is called correctly for every children components that are not used anymore,
calling onDetach method for component TestComponent@52f8cbbd
calling onDetach method for component TestView@6b717784
but when the UI is detached (by missing 3 heartbeats), the method is called only for the RouterLayout main component.
calling onDetach method for component MainLayout@366ff498
Is that a bug or a wanted behaviour ?