diff --git a/src/app/components/modules-diagram/modules-diagram.component.ts b/src/app/components/modules-diagram/modules-diagram.component.ts index b701aeac988e740c29a50945eff8cc63718fb7bb..363c9fd3752e368470014117ed717f078e0b7221 100644 --- a/src/app/components/modules-diagram/modules-diagram.component.ts +++ b/src/app/components/modules-diagram/modules-diagram.component.ts @@ -105,41 +105,47 @@ export class ModulesDiagramComponent implements AfterContentInit, AfterViewCheck } public ngAfterViewInit(): void { - // add click listener on every calculator node in the graph, that - // corresponds to an open module - this.nativeElement.querySelectorAll("g.node").forEach(item => { - if (item.id && this.formIsOpen(item.id)) { - item.style.cursor = "pointer"; - item.addEventListener("click", () => { - this.openCalc(item.id); - }); - } - }); + setTimeout(() => { // clodo trick + // add click listener on every calculator node in the graph, that + // corresponds to an open module + this.nativeElement.querySelectorAll("g.node").forEach(item => { + if (item.id && this.formIsOpen(item.id)) { + item.style.cursor = "pointer"; + item.addEventListener("click", () => { + this.openCalc(item.id); + }); + } + }); + }, 20); // @WARNING keep timeout > the one in ngAfterContentInit() below } public ngAfterContentInit(): void { this.error = false; - mermaid.initialize({ - // theme: "forest" - flowchart: { - curve: "basis" - } - }); - this.nativeElement = this.diagram.nativeElement; - - if (this.hasModules) { - // generate graph description - const graphDefinition = this.graphDefinition(); - // draw - try { - mermaid.render("graphDiv", graphDefinition, (svgCode, bindFunctions) => { - this.nativeElement.innerHTML = svgCode; - }); - } catch (e) { - console.error(e); - this.error = true; + // clodo trick or displaying modules diagram coming from a + // PreBarrage module results in a blank diagram + setTimeout(() => { + mermaid.initialize({ + // theme: "forest" + flowchart: { + curve: "basis" + } + }); + this.nativeElement = this.diagram.nativeElement; + + if (this.hasModules) { + // generate graph description + const graphDefinition = this.graphDefinition(); + // draw + try { + mermaid.render("graphDiv", graphDefinition, (svgCode, bindFunctions) => { + this.nativeElement.innerHTML = svgCode; + }); + } catch (e) { + console.error(e); + this.error = true; + } } - } + }, 10); } public resetZoom() {