Skip to content

Commit

Permalink
Fixed some components not destroying their ViewContainerRef
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrevryghem committed Feb 29, 2024
1 parent 480c7a6 commit 7abf37c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewContainerRef } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewContainerRef, OnDestroy } from '@angular/core';
import { Bundle } from '../../../../core/shared/bundle.model';
import { Item } from '../../../../core/shared/item.model';
import { ResponsiveColumnSizes } from '../../../../shared/responsive-table-sizes/responsive-column-sizes';
Expand All @@ -15,7 +15,7 @@ import { getItemPageRoute } from '../../../item-page-routing-paths';
* Creates an embedded view of the contents. This is to ensure the table structure won't break.
* (which means it'll be added to the parents html without a wrapping ds-item-edit-bitstream-bundle element)
*/
export class ItemEditBitstreamBundleComponent implements OnInit {
export class ItemEditBitstreamBundleComponent implements OnInit, OnDestroy {

/**
* The view on the bundle information and bitstreams
Expand Down Expand Up @@ -63,4 +63,9 @@ export class ItemEditBitstreamBundleComponent implements OnInit {
this.viewContainerRef.createEmbeddedView(this.bundleView);
this.itemPageRoute = getItemPageRoute(this.item);
}

ngOnDestroy(): void {
this.viewContainerRef.clear();
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
import { Component, OnInit, ViewChild, ViewContainerRef, OnDestroy } from '@angular/core';

@Component({
selector: 'ds-item-edit-bitstream-drag-handle',
Expand All @@ -10,7 +10,7 @@ import { Component, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
* Creates an embedded view of the contents
* (which means it'll be added to the parents html without a wrapping ds-item-edit-bitstream-drag-handle element)
*/
export class ItemEditBitstreamDragHandleComponent implements OnInit {
export class ItemEditBitstreamDragHandleComponent implements OnInit, OnDestroy {
/**
* The view on the drag-handle
*/
Expand All @@ -23,4 +23,8 @@ export class ItemEditBitstreamDragHandleComponent implements OnInit {
this.viewContainerRef.createEmbeddedView(this.handleView);
}

ngOnDestroy(): void {
this.viewContainerRef.clear();
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild, ViewContainerRef } from '@angular/core';
import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild, ViewContainerRef } from '@angular/core';
import { Bitstream } from '../../../../core/shared/bitstream.model';
import { cloneDeep } from 'lodash';
import { ObjectUpdatesService } from '../../../../core/data/object-updates/object-updates.service';
Expand All @@ -21,7 +21,7 @@ import { getBitstreamDownloadRoute } from '../../../../app-routing-paths';
* Creates an embedded view of the contents
* (which means it'll be added to the parents html without a wrapping ds-item-edit-bitstream element)
*/
export class ItemEditBitstreamComponent implements OnChanges, OnInit {
export class ItemEditBitstreamComponent implements OnChanges, OnDestroy, OnInit {

/**
* The view on the bitstream
Expand Down Expand Up @@ -72,6 +72,10 @@ export class ItemEditBitstreamComponent implements OnChanges, OnInit {
this.viewContainerRef.createEmbeddedView(this.bitstreamView);
}

ngOnDestroy(): void {
this.viewContainerRef.clear();
}

/**
* Update the current bitstream and its format on changes
* @param changes
Expand Down

0 comments on commit 7abf37c

Please sign in to comment.