Skip to content

Commit ced7b37

Browse files
authored
Merge branch '19.2.x' into skrastev/fix-16082-19.2.x
2 parents 862a6f5 + e7e899e commit ced7b37

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { IgxTreeService } from './tree.service';
1010
import { IgxTreeComponent } from './tree.component';
1111
import { IgxTree, IgxTreeNode, IgxTreeSelectionType } from './common';
1212
import { IgxTreeNodeComponent } from './tree-node/tree-node.component';
13+
import { PlatformUtil } from '../core/utils';
1314

1415
describe('IgxTree - Navigation #treeView', () => {
1516

@@ -780,7 +781,8 @@ describe('IgxTree - Navigation #treeView', () => {
780781
spyOn(nav, 'update_disabled_cache');
781782
spyOn(nav, 'update_visible_cache');
782783
spyOn(nav, 'register');
783-
const tree = new IgxTreeComponent(nav, mockSelectionService, mockTreeService, mockElementRef);
784+
const mockPlatform = jasmine.createSpyObj('platform', ['isBrowser', 'isServer']);
785+
const tree = new IgxTreeComponent(nav, mockSelectionService, mockTreeService, mockElementRef, mockPlatform);
784786
tree.nodes = mockQuery;
785787
expect(nav.register).toHaveBeenCalledWith(tree);
786788
expect(nav.init_invisible_cache).not.toHaveBeenCalled();

projects/igniteui-angular/src/lib/tree/tree-selection.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,9 @@ describe('IgxTree - Selection #treeView', () => {
552552
const selectionService = new IgxTreeSelectionService();
553553
const treeService = new IgxTreeService();
554554
const navService = new IgxTreeNavigationService(treeService, selectionService);
555-
const tree = new IgxTreeComponent(navService, selectionService, treeService, null);
555+
const mockPlatform = jasmine.createSpyObj('platform', ['isBrowser', 'isServer']);
556+
mockPlatform.isBrowser = true;
557+
const tree = new IgxTreeComponent(navService, selectionService, treeService, null, mockPlatform);
556558

557559
beforeEach(() => {
558560
mockNodes = TreeTestFunctions.createNodeSpies(0, 5);

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

Lines changed: 8 additions & 4 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,12 @@ export class IgxTreeComponent implements IgxTree, OnInit, AfterViewInit, OnDestr
501502
private subToChanges() {
502503
this.unsubChildren$.next();
503504
const toBeSelected = [...this.forceSelect];
504-
requestAnimationFrame(() => {
505-
this.selectionService.selectNodesWithNoEvent(toBeSelected);
506-
});
505+
if(this.platform.isBrowser) {
506+
requestAnimationFrame(() => {
507+
this.selectionService.selectNodesWithNoEvent(toBeSelected);
508+
});
509+
}
510+
507511
this.forceSelect = [];
508512
this.nodes.forEach(node => {
509513
node.expandedChange.pipe(takeUntil(this.unsubChildren$)).subscribe(nodeState => {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { IgxTreeNodeComponent } from './tree-node/tree-node.component';
1111
import { IgxTreeSelectionService } from './tree-selection.service';
1212
import { IgxTreeComponent } from './tree.component';
1313
import { IgxTreeService } from './tree.service';
14+
import { PlatformUtil } from '../core/utils';
1415

1516
const TREE_ROOT_CLASS = 'igx-tree__root';
1617
const NODE_TAG = 'igx-tree-node';
@@ -45,8 +46,10 @@ describe('IgxTree #treeView', () => {
4546
mockElementRef = jasmine.createSpyObj('elementRef', [], {
4647
nativeElement: document.createElement('div')
4748
});
49+
const mockPlatform = jasmine.createSpyObj('platform', ['isBrowser', 'isServer']);
50+
mockPlatform.isBrowser = true;
4851
tree?.ngOnDestroy();
49-
tree = new IgxTreeComponent(mockNavService, mockSelectionService, mockTreeService, mockElementRef);
52+
tree = new IgxTreeComponent(mockNavService, mockSelectionService, mockTreeService, mockElementRef, mockPlatform);
5053
mockNodes = jasmine.createSpyObj('mockList', ['toArray'], {
5154
changes: new Subject<void>(),
5255
get first() {

0 commit comments

Comments
 (0)