Skip to content

Commit db710c5

Browse files
Fixed some components not destroying their ViewContainerRef
1 parent 109418b commit db710c5

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewContainerRef } from '@angular/core';
1+
import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewContainerRef, OnDestroy } from '@angular/core';
22
import { Bundle } from '../../../../core/shared/bundle.model';
33
import { Item } from '../../../../core/shared/item.model';
44
import { ResponsiveColumnSizes } from '../../../../shared/responsive-table-sizes/responsive-column-sizes';
@@ -16,7 +16,7 @@ import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
1616
* Creates an embedded view of the contents. This is to ensure the table structure won't break.
1717
* (which means it'll be added to the parents html without a wrapping ds-item-edit-bitstream-bundle element)
1818
*/
19-
export class ItemEditBitstreamBundleComponent implements OnInit {
19+
export class ItemEditBitstreamBundleComponent implements OnInit, OnDestroy {
2020

2121
/**
2222
* The view on the bundle information and bitstreams
@@ -67,4 +67,9 @@ export class ItemEditBitstreamBundleComponent implements OnInit {
6767
this.viewContainerRef.createEmbeddedView(this.bundleView);
6868
this.itemPageRoute = getItemPageRoute(this.item);
6969
}
70+
71+
ngOnDestroy(): void {
72+
this.viewContainerRef.clear();
73+
}
74+
7075
}

src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-drag-handle/item-edit-bitstream-drag-handle.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
1+
import { Component, OnInit, ViewChild, ViewContainerRef, OnDestroy } from '@angular/core';
22

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

26+
ngOnDestroy(): void {
27+
this.viewContainerRef.clear();
28+
}
29+
2630
}

src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream/item-edit-bitstream.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild, ViewContainerRef } from '@angular/core';
1+
import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild, ViewContainerRef } from '@angular/core';
22
import { Bitstream } from '../../../../core/shared/bitstream.model';
33
import cloneDeep from 'lodash/cloneDeep';
44
import { ObjectUpdatesService } from '../../../../core/data/object-updates/object-updates.service';
@@ -21,7 +21,7 @@ import { getBitstreamDownloadRoute } from '../../../../app-routing-paths';
2121
* Creates an embedded view of the contents
2222
* (which means it'll be added to the parents html without a wrapping ds-item-edit-bitstream element)
2323
*/
24-
export class ItemEditBitstreamComponent implements OnChanges, OnInit {
24+
export class ItemEditBitstreamComponent implements OnChanges, OnDestroy, OnInit {
2525

2626
/**
2727
* The view on the bitstream
@@ -72,6 +72,10 @@ export class ItemEditBitstreamComponent implements OnChanges, OnInit {
7272
this.viewContainerRef.createEmbeddedView(this.bitstreamView);
7373
}
7474

75+
ngOnDestroy(): void {
76+
this.viewContainerRef.clear();
77+
}
78+
7579
/**
7680
* Update the current bitstream and its format on changes
7781
* @param changes

0 commit comments

Comments
 (0)