Skip to content

Commit b5f332c

Browse files
committed
chore(tree): implement ngOnDestroy hook in nav service to prevent memory leak
1 parent 2a26308 commit b5f332c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

projects/igniteui-angular/src/lib/tree/tree-navigation.service.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Injectable } from '@angular/core';
1+
import { Injectable, OnDestroy } from '@angular/core';
22
import { IgxTree, IgxTreeNode, IGX_TREE_SELECTION_TYPE } from './common';
33
import { NAVIGATION_KEYS } from '../core/utils';
44
import { IgxTreeService } from './tree.service';
55
import { IgxTreeSelectionService } from './tree-selection.service';
66
import { Subject } from 'rxjs';
77

88
@Injectable()
9-
export class IgxTreeNavigationService {
9+
export class IgxTreeNavigationService implements OnDestroy {
1010
private tree: IgxTree;
1111

1212
private _focusedNode: IgxTreeNode<any> = null;
@@ -131,6 +131,11 @@ export class IgxTreeNavigationService {
131131
}
132132
}
133133

134+
public ngOnDestroy() {
135+
this._cacheChange.next();
136+
this._cacheChange.complete();
137+
}
138+
134139
private handleNavigation(event: KeyboardEvent) {
135140
switch (event.key.toLowerCase()) {
136141
case 'home':

0 commit comments

Comments
 (0)