From 7d18fef6353ee274914159c4e5ff9517ec19f620 Mon Sep 17 00:00:00 2001 From: binglingshuang Date: Thu, 25 Apr 2019 13:03:24 +0800 Subject: [PATCH] fix(module:radio, tab): Fixed memory leak problem. (#3354) * fix(module:radio, tab): Fixed memory leak problem. * fix(module:radio, tab): Fixed memory leak problem. (fix tslint) --- 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..60350138a8f 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(): void { + 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') {