From 2cff8d604b20d723eaedd179b78405d16b5a4797 Mon Sep 17 00:00:00 2001 From: ttonev Date: Thu, 24 Jul 2025 15:56:40 +0300 Subject: [PATCH] refactor(tree): add raf check for tree SSR --- .../igniteui-angular/src/lib/tree/tree.component.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/projects/igniteui-angular/src/lib/tree/tree.component.ts b/projects/igniteui-angular/src/lib/tree/tree.component.ts index 2ee5d39e79f..e6cd75b074d 100644 --- a/projects/igniteui-angular/src/lib/tree/tree.component.ts +++ b/projects/igniteui-angular/src/lib/tree/tree.component.ts @@ -29,7 +29,7 @@ import { IgxTreeNodeComponent } from './tree-node/tree-node.component'; import { IgxTreeSelectionService } from './tree-selection.service'; import { IgxTreeService } from './tree.service'; import { growVerIn, growVerOut } from 'igniteui-angular/animations'; -import { resizeObservable } from '../core/utils'; +import { PlatformUtil, resizeObservable } from '../core/utils'; /** * @hidden @internal @@ -327,6 +327,7 @@ export class IgxTreeComponent implements IgxTree, OnInit, AfterViewInit, OnDestr private selectionService: IgxTreeSelectionService, private treeService: IgxTreeService, private element: ElementRef, + private platform: PlatformUtil ) { this.selectionService.register(this); this.treeService.register(this); @@ -501,9 +502,13 @@ export class IgxTreeComponent implements IgxTree, OnInit, AfterViewInit, OnDestr private subToChanges() { this.unsubChildren$.next(); const toBeSelected = [...this.forceSelect]; - requestAnimationFrame(() => { + if(this.platform.isBrowser) { + requestAnimationFrame(() => { + this.selectionService.selectNodesWithNoEvent(toBeSelected); + }); + } else { this.selectionService.selectNodesWithNoEvent(toBeSelected); - }); + } this.forceSelect = []; this.nodes.forEach(node => { node.expandedChange.pipe(takeUntil(this.unsubChildren$)).subscribe(nodeState => {