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

Destroy old base components on turbo:load

Oliver Güntherbf2f4f6f262e
diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts
index d08f9538010..1837931c2d5 100644
--- a/frontend/src/app/app.module.ts
+++ b/frontend/src/app/app.module.ts
@@ -394,6 +394,14 @@ export class OpenProjectModule implements DoBootstrap {
// Connect ui router to turbo drive
document.addEventListener('turbo:load', () => {
+ // Remove all previous references to components
+ // This is mainly the bsae component
+ appRef.components.slice().forEach((component) => {
+ appRef.detachView(component.hostView);
+ component.destroy();
+ });
+
+ // Run bootstrap again to initialize the new application
this.runBootstrap(appRef);
});
diff --git a/frontend/src/app/shared/components/fields/edit/edit-form/edit-form.component.ts b/frontend/src/app/shared/components/fields/edit/edit-form/edit-form.component.ts
index d6811aa058e..e48ad5fecd9 100644
--- a/frontend/src/app/shared/components/fields/edit/edit-form/edit-form.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/edit-form/edit-form.component.ts
@@ -92,7 +92,6 @@ export class EditFormComponent extends EditForm<HalResource> implements OnInit,
const requiresConfirmation = ConfigurationService.warnOnLeavingUnsaved();
this.unregisterListener = $transitions.onBefore({}, (transition:Transition) => {
- this.removeIdleComponents();
if (!this.editing) {
return undefined;
}
@@ -125,16 +124,6 @@ export class EditFormComponent extends EditForm<HalResource> implements OnInit,
this.globalEditFormChangesTrackerService.removeFromActiveForms(this);
}
- // Hacky fix: remove inactive rendered components which aren't in DOM any more
- removeIdleComponents() {
- this.appRef.components.forEach((component) => {
- const element = ((component.hostView as unknown) as { rootNodes:unknown[] }).rootNodes[0] as HTMLElement;
- if (!document.body.contains(element)) {
- this.appRef.detachView(component.hostView);
- }
- });
- }
-
public async activateField(form:EditForm, schema:IFieldSchema, fieldName:string, errors:string[]):Promise<EditFieldHandler> {
return this.waitForField(fieldName).then((ctrl) => {
ctrl.setActive(true);