Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Avoid boostrap embedded components while app is running change detection

Aleix Suau84e763e80e14
diff --git a/frontend/src/app/globals/dynamic-bootstrapper.ts b/frontend/src/app/globals/dynamic-bootstrapper.ts
index 0e48ffdece3..06858cfcfa2 100644
--- a/frontend/src/app/globals/dynamic-bootstrapper.ts
+++ b/frontend/src/app/globals/dynamic-bootstrapper.ts
@@ -27,6 +27,7 @@
import {ComponentType} from "@angular/cdk/portal";
import {ApplicationRef} from "@angular/core";
+import {filter, take} from "rxjs/operators";
/**
* Optional bootstrap definition to allow selecting all matching
@@ -81,7 +82,17 @@ export class DynamicBootstrapper {
* @param {OptionalBootstrapDefinition[]|undefined} definitions An optional set of components to bootstrap
*/
public static bootstrapOptionalEmbeddable(appRef:ApplicationRef, element:HTMLElement, definitions = this.optionalBoostrapComponents) {
- this.performBootstrap(appRef, element, true, definitions);
+ // Avoid bootstrapping the embedded components while the app
+ // is running the Change Detection ("ApplicationRef.tick
+ // is called recursively" error)
+ appRef
+ .isStable
+ .pipe(
+ filter(isStable => isStable),
+ take(1),
+ )
+ .toPromise()
+ .then(() => this.performBootstrap(appRef, element, true, definitions));
}
/**