Skip to content

Commit e8719c2

Browse files
committed
fix(tree): add rAF handling for SSR/browser
1 parent 160626d commit e8719c2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

projects/igniteui-angular/src/lib/tree/tree.component.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { IgxTreeNodeComponent } from './tree-node/tree-node.component';
2929
import { IgxTreeSelectionService } from './tree-selection.service';
3030
import { IgxTreeService } from './tree.service';
3131
import { growVerIn, growVerOut } from 'igniteui-angular/animations';
32-
import { resizeObservable } from '../core/utils';
32+
import { PlatformUtil, resizeObservable } from '../core/utils';
3333

3434
/**
3535
* @hidden @internal
@@ -327,6 +327,7 @@ export class IgxTreeComponent implements IgxTree, OnInit, AfterViewInit, OnDestr
327327
private selectionService: IgxTreeSelectionService,
328328
private treeService: IgxTreeService,
329329
private element: ElementRef<HTMLElement>,
330+
private platform: PlatformUtil
330331
) {
331332
this.selectionService.register(this);
332333
this.treeService.register(this);
@@ -501,9 +502,13 @@ export class IgxTreeComponent implements IgxTree, OnInit, AfterViewInit, OnDestr
501502
private subToChanges() {
502503
this.unsubChildren$.next();
503504
const toBeSelected = [...this.forceSelect];
504-
requestAnimationFrame(() => {
505+
if(this.platform.isBrowser) {
506+
requestAnimationFrame(() => {
507+
this.selectionService.selectNodesWithNoEvent(toBeSelected);
508+
});
509+
} else {
505510
this.selectionService.selectNodesWithNoEvent(toBeSelected);
506-
});
511+
}
507512
this.forceSelect = [];
508513
this.nodes.forEach(node => {
509514
node.expandedChange.pipe(takeUntil(this.unsubChildren$)).subscribe(nodeState => {

0 commit comments

Comments
 (0)