Skip to content

Commit

Permalink
fix(module:radio, tab): Fixed memory leak problem. (#3354)
Browse files Browse the repository at this point in the history
* fix(module:radio, tab): Fixed memory leak problem.

* fix(module:radio, tab): Fixed memory leak problem. (fix tslint)
  • Loading branch information
binglingshuang authored and vthinkxie committed Apr 25, 2019
1 parent 19f9344 commit 7d18fef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion components/radio/nz-radio.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
HostListener,
Input,
OnChanges,
OnDestroy,
Renderer2,
SimpleChanges,
ViewChild,
Expand Down Expand Up @@ -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<NzRadioComponent>();
touched$ = new Subject<void>();
checked = false;
Expand Down Expand Up @@ -140,4 +141,8 @@ export class NzRadioComponent implements ControlValueAccessor, AfterViewInit, On
this.updateAutoFocus();
}
}

ngOnDestroy(): void {
this.focusMonitor.stopMonitoring(this.elementRef);
}
}
9 changes: 8 additions & 1 deletion components/tabs/nz-tabs-nav.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
EventEmitter,
Input,
NgZone,
OnDestroy,
Optional,
Output,
QueryList,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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') {
Expand Down

0 comments on commit 7d18fef

Please sign in to comment.