FlowingCode / OrgChartAddon

Organizational Chart Vaadin Add-on
https://www.flowingcode.com/en/open-source/
Apache License 2.0
18 stars 4 forks source link

Component requieres call to `initializeChart` every time it's added #37

Closed javier-godoy closed 3 years ago

javier-godoy commented 4 years ago

The following code requieres a call to initializeChart when the component is added. Why is it so? Can't it be handled on attach and/or by setting properties through Element API?

OrgChart og = new OrgChart(new OrgChartItem(1, "name", "title"));
og.initializeChart();
add(og, new Button("Toggle", ev -> {
    if (getChildren().anyMatch(og::equals)) {
        remove(og);
    } else {
        add(og);
        og.initializeChart(); //(?)
    }
}));
mlopezFC commented 4 years ago

I think that is mainly because it was originally designed to work with Vaadin 8. I did a small local test and it seems to work fine by moving the initialization to an onAttach() method