From 253106f516583f2d7bdc49046db9329fa1b70d7a Mon Sep 17 00:00:00 2001 From: "yongshuang.wang" Date: Wed, 24 Apr 2019 15:10:58 +0800 Subject: [PATCH 1/2] fix(module:radio, tab): Fixed memory leak problem. --- components/radio/nz-radio.component.ts | 7 ++++++- components/tabs/nz-tabs-nav.component.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/components/radio/nz-radio.component.ts b/components/radio/nz-radio.component.ts index 45a33dd74f9..5a943d01a30 100644 --- a/components/radio/nz-radio.component.ts +++ b/components/radio/nz-radio.component.ts @@ -17,6 +17,7 @@ import { HostListener, Input, OnChanges, + OnDestroy, Renderer2, SimpleChanges, ViewChild, @@ -46,7 +47,7 @@ import { InputBoolean } from 'ng-zorro-antd/core'; '[class.ant-radio-wrapper-disabled]': 'nzDisabled' } }) -export class NzRadioComponent implements ControlValueAccessor, AfterViewInit, OnChanges { +export class NzRadioComponent implements ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy { select$ = new Subject(); touched$ = new Subject(); checked = false; @@ -140,4 +141,8 @@ export class NzRadioComponent implements ControlValueAccessor, AfterViewInit, On this.updateAutoFocus(); } } + + ngOnDestroy() { + this.focusMonitor.stopMonitoring(this.elementRef); + } } diff --git a/components/tabs/nz-tabs-nav.component.ts b/components/tabs/nz-tabs-nav.component.ts index 74614e5f5bd..20504b56c3d 100644 --- a/components/tabs/nz-tabs-nav.component.ts +++ b/components/tabs/nz-tabs-nav.component.ts @@ -19,6 +19,7 @@ import { EventEmitter, Input, NgZone, + OnDestroy, Optional, Output, QueryList, @@ -47,7 +48,7 @@ export type ScrollDirection = 'after' | 'before'; encapsulation: ViewEncapsulation.None, templateUrl: './nz-tabs-nav.component.html' }) -export class NzTabsNavComponent implements AfterContentChecked, AfterContentInit { +export class NzTabsNavComponent implements AfterContentChecked, AfterContentInit, OnDestroy { private _tabPositionMode: NzTabPositionMode = 'horizontal'; private _scrollDistance = 0; private _selectedIndex = 0; @@ -174,6 +175,12 @@ export class NzTabsNavComponent implements AfterContentChecked, AfterContentInit }); } + ngOnDestroy(): void { + if (this.realignInkBar) { + this.realignInkBar.unsubscribe(); + } + } + updateTabScrollPosition(): void { const scrollDistance = this.scrollDistance; if (this.nzPositionMode === 'horizontal') { From 539ad0a6bb20f5fade6d2e04a6670ba76e538352 Mon Sep 17 00:00:00 2001 From: binglingshuang Date: Wed, 24 Apr 2019 16:51:12 +0800 Subject: [PATCH 2/2] fix(module:radio, tab): Fixed memory leak problem. (fix tslint) --- components/radio/nz-radio.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/radio/nz-radio.component.ts b/components/radio/nz-radio.component.ts index 5a943d01a30..60350138a8f 100644 --- a/components/radio/nz-radio.component.ts +++ b/components/radio/nz-radio.component.ts @@ -142,7 +142,7 @@ export class NzRadioComponent implements ControlValueAccessor, AfterViewInit, On } } - ngOnDestroy() { + ngOnDestroy(): void { this.focusMonitor.stopMonitoring(this.elementRef); } }